/** * Initialization */ public function init() { parent::init(); $this->app->jquery = $this; if (!$this->app->template) { return; } if (!$this->app->template->is_set('js_include')) { throw $this->exception('Tag js_include must be defined in shared.html'); } if (!$this->app->template->is_set('document_ready')) { throw $this->exception('Tag document_ready must be defined in shared.html'); } $this->app->template->del('js_include'); /* $config['js']['jquery']='https://code.jquery.com/jquery-2.1.4.min.js'; // to use CDN */ if ($v = $this->app->getConfig('js/versions/jquery', null)) { $v = 'jquery-' . $v; } else { $v = $this->app->getConfig('js/jquery', 'jquery-2.2.1.min'); // bundled jQuery version } $this->addInclude($v); // Controllers are not rendered, but we need to do some stuff manually $this->app->addHook('pre-render-output', array($this, 'postRender')); $this->app->addHook('cut-output', array($this, 'cutRender')); }
public function init() { parent::init(); if (@$_GET[$this->owner->name . '_cut_field'] == $this->name) { $this->app->addHook('pre-render', array($this, '_cutField')); } /* TODO: finish refactoring // find the form $obj=$this->owner; while(!$obj instanceof Form){ if($obj === $this->app)throw $this->exception('You must add fields only inside Form'); $obj = $obj->owner; } $this->setForm($obj); */ }
public function init() { /* * During form initialization it will go through it's own template and * search for lots of small template chunks it will be using. If those * chunk won't be in template, it will fall back to default values. * This way you can re-define how form will look, but only what you need * in particular case. If you don't specify template at all, form will * work with default look. */ parent::init(); $this->getChunks(); // After init method have been executed, it's safe for you to add // controls on the form. BTW, if you want to have default values such as // loaded from the table, then intialize $this->data array to default // values of those fields. $this->app->addHook('pre-exec', array($this, 'loadData')); $this->app->addHook('pre-render-output', array($this, 'lateSubmit')); $this->app->addHook('submitted', array($this, 'submitted')); $this->addHook('afterAdd', array($this, 'afterAdd')); }
/** * Called after on post-init hook when form is submitted. * * @param Form $form Form which was submitted */ protected function formSubmit($form) { try { $form->update(); $self = $this; $this->app->addHook('pre-render', function () use($self) { $self->formSubmitSuccess()->execute(); }); } catch (Exception_ValidityCheck $e) { $form->displayError($e->getField(), $e->getMessage()); } }
public function init() { parent::init(); $this->app->router = $this; $this->app->addHook('buildURL', array($this, 'buildURL')); }