Skip to content

Latest commit

 

History

History
88 lines (87 loc) · 4.65 KB

File metadata and controls

88 lines (87 loc) · 4.65 KB

definition(s) for valid struct for \handcode\dynamicFormModel\DynamicFormModel

  • formName:

    • scope:
      • root level
    • desc:
      • formName of the model used in activeForms to namespace the properties of the dynamic model
  • properties

    • scope:
      • root level
      • property option for properties of type object
    • type: null|string[]|array
      • if null
        • attributes for the model can be provided via constructor
        • see: \handcode\dynamicFormModel\DynamicFormModel::$useConstructorAttributes
      • if string[]
        • string array items are treated as property names
        • rules and input definitions are used from defaults
      • if array, key => value pairs can be:
        • type:
          • type: string
          • value can be attribute or object
          • if object it will be initialized as a child DynamicFormModel with its options as struct and therefor MUST have an options array with min. properties defined
        • value:
          • typ: mixed
          • current/default value; values can also provided via contructor init
          • see: \handcode\dynamicFormModel\DynamicFormModel::$useConstructorAttributes
        • input: @input-ref
        • rules: @rules-ref
        • fieldset: @fieldset-ref
        • hint:
          • type: null|string
          • the attributeHint
        • label:
          • type: null|string
          • the attributeLabel
        • properties: @properties-ref
          • only valid in type object properties
  • input:

    • scope:
      • if used as root property, it defines the default input used for all properties without specific input config
      • if used as property option it defines the input for the specific property
      • if used as property type object option it defines the default input for the child Object
    • type: null|string|array
      • if string:
        • value is used as input type, see yii ActiveField Types
      • if array key value pairs can be:
        • string: if no callback, type or widget is defined, the first array item is used as type, like yii do with className config in various places
        • options: array of options for the activeInputField, if not set all array items without "special usage" are used
        • inputCallback:
          • will be called with inputCallback(ActiveForm $form, Model $model, string $property, array $options) and should return the ActiveForm Input.
          • if defined, type, widget, etc. will be ignored and "the rest of the input config will be used as callback $options param
          • can be used at top level of the struct to define default input type
          • or as key in the subarray within on property definition
        • widget:
          • can be used inside a input config array to define a widgetClass name that should be used as inputWidget
          • if set, KEY_INPUT_TYPE will be ignored
        • itemsCallback:
          • can be used inside a self::KEY_INPUT config array to define a callback which will be called to get the items array that should be used as items param when initializing a list input like dropDownList, checkBoxList,...
          • as the items array will be used as items param before options, it should only be declared IF a list input defined as type!
        • items:
          • can be used inside a self::KEY_INPUT config array to define the items array that should be used as items param when initializing a list input like dropDownList, checkBoxList,...
          • The array is used "as is" so you have to define proper key => value pairs
          • as the items array will be used as items param before options, it should only be declared IF a list input defined as type!
        • itemValues:
          • nearly the same as items
          • difference: the given values are mapped as key => value pairs, so you can define simple arrays as items
  • rules:

    • scope:
      • if used as root property, it defines the default rules used for all properties without specific rules config
      • if used as property option it defines the rules for the specific property
      • if used as property type object option it defines the default rules for the child Object
    • syntax:
      • array of valid validation rules WITHOUT the first param (the property name)
      • The property name will be appended dynamically in the rule while initializing the properties from struct
  • fieldset:

    • type: null|string
    • scope:
      • at root the default for all properties without specific fieldset config
      • as property config the group for the specific property
    • desc: name of the form input group