/framework/vendor/smarty2/plugins/function.bind.php

http://zoop.googlecode.com/ · PHP · 17 lines · 15 code · 1 blank · 1 comment · 5 complexity · f18b693c866d58d47d30b8760465158c MD5 · raw file

  1. <?php
  2. function smarty_function_bind($params, &$smarty)
  3. {
  4. assert(isset($params['data_object']));
  5. // handle the data bindings
  6. if(!isset($params['data_field']))
  7. trigger_error("gui:bind: if you specifiy a data object you must also specify a data field");
  8. if(!isset($smarty->pehppy->form))
  9. trigger_error("gui:bind: if you specifiy a data object you must first use the 'init_form' tag");
  10. $object = $params['data_object'];
  11. $field = $params['data_field'];
  12. if(isset($params['assign']))
  13. $smarty->assign($params['assign'], $smarty->pehppy->form->addBinding(get_class($object), $object->getId(), $field));
  14. else
  15. return $smarty->pehppy->form->addBinding(get_class($object), $object->getId(), $field);
  16. }