Hi again,
yes, today I've got many questions. Sorry for that, but I cleaning up my code and want to improve it.
My next question is about User Options of an form-element.
In the docs there is nothing said about the functionality: https://docs.phalcon.io/en/latest/reference/forms.html#setting-user-options (paragraph is empty)
I use classes to build my forms and I've written a base-class with a function renderDecorated that does the right html-code for bootstrap.
I wanted to be able to provide helptext for form-elements and instead of extended every element-class of phalcon, I thought: Why not doing something like this in the form-class:
private function elementBaseUri ($value) { $element = new Text('baseUri', array( 'id' => 'baseUri', 'required' => 'required', 'class' => 'form-control', 'value' => $value, 'placeholder' => $this->translate->("FORMS_SYSTEMSETTINGS_BASEURIPLACEHOLDER") )); $element->setLabel($this->translate->("FORMS_SYSTEMSETTINGS_BASEURI_LABEL")); $element->setUserOption('helptext', 'FORMS_SYSTEMSETTINGS_BASEURIHELPTEXT'); $element->addValidators(array( new PresenceOf(array( 'message' => $this->translate->('ERROR_FORMS_VALIDATION_FIELD_PRESENCEOF', array('field'=>'baseUri')) )) )); return $element; }
And my renderDecorated-method does something like this:
if ($this->getUserOption('helptext', NULL) != NULL) echo "\t", '<p class="help-block">', $this->getUserOption('helptext'), '</p>', PHP_EOL;
But a var_dump says me, that getUserOption returns NULL.
So for what is setUserOption good for?
Thx alot - again