Incomplete Documentation

I’ve been learning Yii2.0 (and developing a new app) for last 3 months.

As expected it’s quite a difficult and steep learning curve but I’m persevering…

One thing I am noticing though is when using the provided docs I seem to get to dead ends.

ie: the trail of information seems to end…

e.g.

"Creating Forms"

http://www.yiiframework.com/doc-2.0/guide-input-forms.html

If I look at example code


$form = ActiveForm::begin([

    'id' => 'login-form',

    'options' => ['class' => 'form-horizontal'],

And in the description below it says…

"As with any widget, you can specify some options as to how the widget should be configured by passing an array to the begin method. In this case, an extra CSS class and identifying ID are passed to be used in the opening <form> tag. For all available options, please refer to the API documentation of yii\widgets\ActiveForm."

After clicking link in documentation and searching for begin() it tells me this…


public static static begin ( $config = [] )

OK - I’m getting closer to the truth…


$config	array   Name-value pairs that will be used to initialize the object properties

And that’s it?

No mention of


'options' => ['class' => 'form-horizontal']

Where are the exact parameters that such a function offers?

How can I find that level of information out???

(my current problem is getting my model to output a list of checkboxes, dynamically "checked" depending on a search from my controller)

Any advice on being able to read or understand how the documanetation can serve me better would be greatly appreciated.

Hi,

Like described here:

http://www.yiiframework.com/doc-2.0/yii-widgets-activeform.html

"The HTML attributes (name-value pairs) for the form tag."

Means the "options" array will be translated like in following examples:

For example:




$form = ActiveForm::begin([

'id' => 'login-form',

'options' => [

    'class' => 'form-horizontal', 

    'style' => 'awesome-something',

],



becomes translated to:




<form id="login-form" class="form-horizontal" style="awesome-something">



Means you can use "options" to attach whatever you want to the current tag.

For example you could also write:




$form = ActiveForm::begin([

'options' => [

    // id defined inside "options"

    'id' => 'login-form',

    'something-i-want-to-add' => 'my-custom-attribute'

],



Which will generate:




<form id="login-form" something-i-want-to-add="my-custom-attribute">



Hope this makes it a littlebit more clear for you?

Best Regards

Thank you - perfect!!!!!!!

:D :D :D