This repository was archived by the owner on Dec 2, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
AIIXForm Data
ailixter edited this page Mar 5, 2016
·
11 revisions
[firstname]
-control = text
-label = "First Name"
class = userdata
style = font-size:150%
[text1]
-control = text
-label[-text] = "Text 1"
-label[class] = redtext
class[] = class0
class[] = class2
style[] = font-size:82%
style[] = font-weight:bold
[text2]
-control = text
-label = @shared-label
class = @shared-class
style = @shared-style
[@shared-label]
-text = "Text 1"
class = redtext
[@shared-class]
a = class0
b = class2
[@shared-style]
x = font-size:82%
y = font-weight:bold
- button -
<button type="{{type}}">{{-label}}</button> - inputbutton -
<input type="{{type}}" value="{{-label}}"/> - input -
<input type="{{type}}"/> - hidden -
<input type="hidden"/> - password -
<input type="password"/> - file -
<input type="file"/> - checkbox -
<input type="checkbox"/> - radio -
<input type="radio"/> - select -
<select>{{-options...}}</select>
[labeled1]
-label = "Labeled Control"<label for="labeled1">Labeled Control</label>
<input id="labeled1 type="text"/>[labeled2]
-label = "Labeled Control"
-label-data[class] = test
-label-data[title] = "Just for fun"<label class="test" title="Just for fun" for="labeled2">Labeled Control</label>[labeled3]
-label[-text] = "Complex"
-label[class] = test
[labeled4]
-label = @some-label
[@some-label]
-text = "Complex"
class = test<label class="test" for="labeled3">Complex</label>
<label class="test" for="labeled4">Complex</label>[labeled5]
-label.en = "Age"
-label.ru = "Возраст"<!-- if AIIXForm mod == '.ru' -->
<label for="labeled5">Возраст</label>see also AIIXForm and i18n
; no labeled6<label for="labeled6">labeled6</label>[amount]
-control = text
-default = 100<!-- if !isset($_REQUEST['amount']) -->
<input type="text" name="amount" value="100"/>
<!-- if $_REQUEST['amount'] == 235 -->
<input type="text" name="amount" value="235"/>[integer]
-filter[FILTER_VALIDATE_INT] = null ; no filter options
[1-to-3]
-filter[FILTER_VALIDATE_INT] = @1-to-3 ; use filter options
[@1-to-3]
options[min_range] = 1
options[max_range] = 3
[date]
-filter [FILTER_VALIDATE_REGEXP] = @ansi-date
[@ansi-date]
options[regexp] = /^\d{4}-\d{2}-\d{2}$|^$/\AIIX\Form::validate("validate$i.0")
or print_r(\AIIX\Form::message("validate$i.0"));[validate0.0]
-validate = required array (
'required' => '{-label} required ' ; {-label} method args
)
[validate1.0]
-validate = required
-message[required] = "validate1.0 must be specified" array (
'required' => 'validate1.0 must be specified'
)
[validate2.0]
-validate[required] = "This field" ; parameter
-message[required] = "%s must be specified" array (
'required' => 'This field must be specified'
)
class Custom {
function validate_custom ($path, $filtered, $args) {
$valid_if_true = $filtered === $args;
\AIIX\Form::msgIfFalse($valid_if_true, $path, 123, 'custom key');
}
}
$controller = new Custom;
\AIIX\Form::validate("validate$i.0", $controller)
or print_r(\AIIX\Form::message("validate$i.0"));[validate3.0]
-label = "John"
-validate[required] = null ; no parameter
-validate[custom] = "param" ; parameter
-message[required] = "{-label} %s must be specified"
-message[custom key]= "It's not valid"
[validate3.1]
-label = "Mary"
-validate[required] = null ; no parameter
-validate[custom] = "xyz" ; parameter, see validate_custom() above
-message[required] = "Specify validate1.1"
-message[custom key]= "{-label} still not valid (error %s)"'3.0' =>
array (
'required' => 'John must be specified',
'custom key' => 'It\'s not valid'
),
'3.1' =>
array (
'custom key' => 'Mary still not valid (error 123)',
)
[test2]
-suffix = 'product/id'<input id="test2_product_id" name="test2[product][id]" type="text"/>Notice the -path, you wouldn't want to set it:
$attrs_with_path = \AIIX\Form::attrs('test2');$attrs_with_path: array (
'-suffix' => 'product/id',
'id' => 'test2',
'name' => 'test2',
'-path' => 'test2/product/id',
);
but could use it in some case:
$aiixform = \AIIX\Form::choose();
$test2_product_id = $aiixform->input->get($aiixform->get('test2/-path'));[single]
-control = checkbox<input type="checkbox" name="single"/>[multi]
-control = checkbox
-array = yes<input type="checkbox" name="multi[]"/>[multi]
-control = select
-array = yes
multiple = yes<select name="multi[]">...</select>see also: Control Arrays
[sex]
-control = select
-options = Male||Female
[sex]
-control = select
-options[m] = Male
-options[f] = Female
[sex]
-control = select
-options = @sex
[@sex]
m[-label] = Male
m[class] = bluetext
f[-label] = Female
f[class] = pinktext[important]
-control = text
[ignored]
; notice no -control
value = "Will be ignored!"
[neglected]
-control = radio
-dont-enumerate = yesecho "controls:\n"
foreach (\AIIX\Form::controls() as $control_id => $attrs) {
echo "\t$control_id: ";
print_r($attrs);
}
echo "\nend";prints:
controls:
important: array('id'=>important,...)
end
TODO