Hannik Hannik - 3 months ago 21
PHP Question

phalcon form add options

i have a problem with phalcon form. i added a form but i can not add options like

[
'id' => 'login-form',
'class' => 'form form-x',
'data-form-style' => 'dynamic, rootable, hash',
'data-encrypt' => 'false'
]


i want to add all of them which called setuserOption in phalcon document but i can't do that .

//form add user options
$this->setuserOptions(
[
'id' => 'login-form',
'class' => 'form form-x',
'data-form-style' => 'dynamic, rootable, hash',
'data-encrypt' => 'false'
]
);

//my form
$this->setuserOptions([
'id' => 'login-form',
'class' => 'form form-x',
'data-form-style' => 'dynamic, rootable, hash',
'data-encrypt' => 'false'
]);

}

//this is volt ( form.options is written by me .how can i use this options )
{{ content() }}

{{ form('login/login', form.options) }}
<div class="form-group">
{{ form.label('username') }}
{{ form.render('username', ['class': 'form-control']) }}
</div>
<div class="form-group">
{{ form.label('password') }}
{{ form.render('password', ['class': 'form-control']) }}
</div>
<div class="form-group">
{{ form.render('submit', ['class': 'btn btn-primary btn-large']) }}
</div>
</form>

Answer

If you look at the documentation, you can add properties to you form tag like this:

<?php
 echo Phalcon\Tag::form(array("posts/save", "method" => "post"));

or with the Volt syntax:

<?php
 {{ form("posts/save", "method": "post") }}
Comments