1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109:
<?php
/**
* MvcCore
*
* This source file is subject to the BSD 3 License
* For the full copyright and license information, please view
* the LICENSE.md file that are distributed with this source code.
*
* @copyright Copyright (c) 2016 Tom Flidr (https://github.com/mvccore)
* @license https://mvccore.github.io/docs/mvccore/5.0.0/LICENCE.md
*/
namespace MvcCore\Ext\Forms\Fields;
/**
* Responsibility: define getters and setters for field property `options`.
* Interface for classes:
* - `\MvcCore\Ext\Forms\Fields\DataList`
* - `\MvcCore\Ext\Forms\Fields\Select`
* - `\MvcCore\Ext\Forms\Fields\CountrySelect`
* - `\MvcCore\Ext\Forms\FieldsGroup`
* - `\MvcCore\Ext\Forms\CheckboxGroup`
* - `\MvcCore\Ext\Forms\RadioGroup`
* - `\MvcCore\Ext\Forms\Validators\ValueInOptions`
*/
interface IOptions {
/**
* Set form control or group control options to render
* more values for more specified submitted keys.
*
* Example:
* ```
* // To configure for example radio buttons named: `gender` for `Female` and `Male`:
* // <label for="gender-f">Female:</label>
* // <input id="gender-f" type="radio" name="gender" value="f" />
* // <label for="gender-m">Male:</label>
* // <input id="gender-m" type="radio" name="gender" value="m" />
* // use this configuration:
* $field->SetName('gender')->SetOptions(array(
* // field values will be automatically translated,
* // if form has configured translator `callable`
* 'f' => 'Female',
* 'm' => 'Male',
* ));
*
* // Or you can use more advanced configuration with css class names
* // and html element attributes, let's consider html code like this:
* // <label for="gender-f" class="female">Female:</label>
* // <input id="gender-f" type="radio" name="gender" value="f" class="female" data-any="something-for-females" />
* // <label for="gender-m" class="male">Male:</label>
* // <input id="gender-m" type="radio" name="gender" value="m" class="male" data-any="something-for-males" />
* // For that use this configuration:
* $field->SetName('gender')->SetOptions(array(
* 'f' => array(
* 'text' => 'Female', // text key will be also automatically translated
* 'class' => 'female',
* 'attrs' => array('data-any' => 'something-for-females'),
* ),
* 'm' => array(
* 'text' => 'Male', // text key will be also automatically translated
* 'class' => 'male',
* 'attrs' => array('data-any' => 'something-for-males'),
* ),
* ));
* ```
* @param array $options
* @return \MvcCore\Ext\Forms\Field
*/
public function SetOptions (array $options = []);
/**
* Add form control or group control options to render
* more values for more specified submitted keys.
* Previous options will be merged with given options.
* @param array $options
* @return \MvcCore\Ext\Forms\Field
*/
public function AddOptions (array $options = []);
/**
* Return reference to configured options array.
* @return array
*/
public function & GetOptions ();
/**
* Set `FALSE` if you don't want to translate options texts, default `TRUE`.
* @param bool $translateOptions
* @return \MvcCore\Ext\Forms\Field
*/
public function SetTranslateOptions ($translateOptions = TRUE);
/**
* Return boolean if options are translated or not.
* @return array
*/
public function GetTranslateOptions ();
/**
* Merge given field options with possible grouped options into single
* level flatten array for submit checking purposes.
* @param array|NULL $fieldOptions
* @return array
*/
public function & GetFlattenOptions (array $fieldOptions = NULL);
}