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: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210:
<?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;
interface IView {
/**
* Get global views forms directory placed by default
* inside `"/App/Views"` directory.
* Default value is `"Forms"`, so scripts app path
* is `"/App/Views/Forms"`.
* @return string
*/
public static function GetFormsDir ();
/**
* Set global views forms directory placed by default
* inside `"/App/Views"` directory.
* Default value is `"Forms"`, so scripts app path
* is `"/App/Views/Forms"`.
* @param string $formsDir
* @return string
*/
public static function SetFormsDir ($formsDir = 'Forms');
/**
* Get global views fields directory placed by default
* inside `"/App/Views"` directory.
* Default value is `"Forms/Fields"`, so
* scripts app path is `"/App/Views/Forms/Fields"`.
* @return string
*/
public static function GetFieldsDir ();
/**
* Set global views fields directory placed by default
* inside `"/App/Views"` directory.
* Default value is `"Forms/Fields"`, so
* scripts app path is `"/App/Views/Forms/Fields"`.
* @param string $fieldsDir
* @return string
*/
public static function SetFieldsDir ($fieldsDir = 'Forms/Fields');
/**
* Get controller instance as reference.
* @return \MvcCore\View
*/
public function GetView ();
/**
* Set controller and it's view instance.
* @param \MvcCore\View $view
* @return \MvcCore\Ext\Forms\View
*/
public function SetView (\MvcCore\IView $view);
/**
* Get form instance to render.
* @return \MvcCore\Ext\Form
*/
public function GetForm ();
/**
* Set form instance to render.
* @param \MvcCore\Ext\Form $form
* @return \MvcCore\Ext\Forms\View
*/
public function SetForm (\MvcCore\Ext\IForm $form);
/**
* Get rendered field.
* @return \MvcCore\Ext\Forms\Field
*/
public function GetField ();
/**
* Set rendered field.
* @param \MvcCore\Ext\Forms\Field $field
* @return \MvcCore\Ext\Forms\View
*/
public function SetField (\MvcCore\Ext\Forms\IField $field);
/**
* Get any value by given name existing in local store. If there is no value
* in local store by given name, try to get result value into store by
* field reflection class from field instance property if view is used for
* field rendering. If there is still no value found, try to get result value
* into store by form reflection class from form instance property and if
* still no value found, try to get result value from local view instance
* `__get()` method.
* @param string $name
* @return mixed
*/
public function __get ($name);
/**
* Get `TRUE` by given name existing in local store. If there is no value
* in local store by given name, try to get result value into store by
* field reflection class from field instance property if view is used for
* field rendering. If there is still no value found, try to get result value
* into store by form reflection class from form instance property and if
* still no value found, try to get result value from local view instance
* `__get()` method.
* @param string $name
* @return bool
*/
public function __isset ($name);
/**
* Call public field method if exists in field instance and view is used for
* field rendering or call public form method if exists in form instance or
* try to call view helper by parent `__call()` method.
* @param string $method
* @param mixed $arguments
* @return mixed
*/
public function __call ($method, $arguments);
/**
* Render configured form template.
* @return string
*/
public function RenderTemplate ();
/**
* Render form naturally by cycles inside php scripts.
* All form fields will be rendered inside empty <div> elements.
* @return string
*/
public function RenderNaturally ();
/**
* Render form begin.
* Render opening <form> tag and hidden input with CSRF tokens.
* @return string
*/
public function RenderBegin ();
/**
* Render hidden input with CSRF tokens.
* This method is not necessary to call, it's
* called internally by `$form->View->RenderBegin();`
* @return string
*/
public function RenderCsrf ();
/**
* Return current CSRF (Cross Site Request Forgery) hidden
* input name and it's value as `\stdClass`.
* Result `\stdClass` has keys: `name` and `value`.
* @return \stdClass
*/
public function GetCsrf ();
/**
* Render form errors.
* If form is configured to render all errors together at form beginning,
* this function completes all form errors into `div.errors` with `div.error` elements
* inside containing each single errors message.
* @return string
*/
public function RenderErrors ();
/**
* Render form content - form fields.
* Go through all `$form->fields` and call `$field->Render();` on every field
* and put it into an empty `<div>` element. Render each field in full possible
* way - naturally by label configuration with possible errors configured beside
* or with custom field template.
* @return string
*/
public function RenderContent ();
/**
* Render form end.
* Render html closing `</form>` tag and supporting javascript and css files
* if is form not using external js/css renderers.
* @return string
*/
public function RenderEnd ();
/**
* Format string function.
* @param string $str Template with replacements like `{0}`, `{1}`, `{anyStringKey}`...
* @param array $args Each value under it's index is replaced as
* string representation by replacement in form `{arrayKey}`
* @return string
*/
public static function Format ($str = '', array $args = []);
/**
* Render content of html tag attributes by key/value array.
* @param array $attributes
* @return string
*/
public static function RenderAttrs (array $attributes = []);
}