Permalink
Browse files

update to version 2.0

  • Loading branch information...
1 parent cc16418 commit 5d8cce4b0182f9a196117230e1e9ea4c9ac683bb @migliori committed Jul 3, 2016
Showing with 40 additions and 4 deletions.
  1. +18 −0 Main.sublime-menu
  2. +3 −0 PHP Form Builder.py
  3. +7 −3 PHP Form Builder.sublime-completions
  4. +2 −1 messages.json
  5. +10 −0 messages/2.0.0.md
View
@@ -10,9 +10,24 @@
"caption": "new Form()",
"command": "completion_trigger", "args": {"completionTriggerText": "newForm"}
}, {
+ "caption": "setOptions()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "setOptions"}
+ }, {
"caption": "setAction()",
"command": "completion_trigger", "args": {"completionTriggerText": "setAction"}
}, {
+ "caption": "setMethod()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "setMethod"}
+ }, {
+ "caption": "addHtml()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "addHtml"}
+ }, {
+ "caption": "setCols()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "setCols"}
+ }, {
+ "caption": "addIcon()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "addIcon"}
+ }, {
"caption": "startFieldset()",
"command": "completion_trigger", "args": {"completionTriggerText": "startFieldset"}
}, {
@@ -93,6 +108,9 @@
}, {
"caption": "Form::clear()",
"command": "completion_trigger", "args": {"completionTriggerText": "FormClear"}
+ }, {
+ "caption": "Form::testToken()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "FormTestToken"}
}]
}]
}]
View
@@ -17,10 +17,13 @@ def run(self, edit):
'new Form($form_ID, $layout = \'horizontal\', $attr = \'\');',
'setAction($url, $add_get_vars = true)',
'setOptions();',
+ 'setMethod($method);',
'startFieldset($legend = \'\')',
'endFieldset()',
'startDependantFields($parent_field, $show_values)',
'endDependantFields()',
+ 'setCols($labelsCols, $fieldsCols, $breakpoint = \'sm\')',
+ 'addIcon($input_name, $icon_html, $pos)',
'addInput--function--($type, $name, $value = \'\', $label = \'\', $attr = \'\')',
'addInputWrapper($html, $element_name)',
'groupInputs($input1, $input2, $input3 = \'\')',
@@ -4,11 +4,14 @@
"completions":
[
{ "trigger": "setOptions();", "contents": "\\$options = array(\n 'horizontalLabelCol' => 'col-sm-${1:4}',\n 'horizontalOffsetCol' => 'col-sm-offset-${1:4}',\n 'horizontalElementCol' => 'col-sm-${2:8}',\n);\n\\$form->setOptions(\\$options);" },
- { "trigger": "newForm", "contents": "use phpformbuilder\\Form;\nuse phpformbuilder\\Validator\\Validator;\n\n@session_start();\ninclude_once rtrim(\\$_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/${1:phpformbuilder}/Form.php';\n/* =============================================\n validation if posted\n============================================= */\n\nif (\\$_SERVER[\"REQUEST_METHOD\"] == \"POST\") {\n include_once '${1:phpformbuilder}/Validator/Validator.php';\n include_once '${1:phpformbuilder}/Validator/Exception.php';\n \\$validator = new Validator(\\$_POST);\n \\$required = array('name', 'first-name');\n foreach (\\$required as \\$required) {\n \\$validator->required()->validate(\\$required);\n }\n // check for errors\n\n if (\\$validator->hasErrors()) {\n \\$_SESSION['errors']['${2:my-form}'] = \\$validator->getAllErrors();\n } else {\n \\$from_email = '${3:you@your-email.com}';\n \\$adress = '${3:you@your-email.com}';\n \\$subject = '${4:Email Subject}';\n \\$filter_values = '${2:my-form}, submit-btn';\n \\$sent_message = Form::sendMail(\\$from_email, \\$adress, \\$subject, \\$filter_values);\n Form::clear('${2:my-form}');\n }\n}\n\\$form = new Form('${2:my-form}');\n\\$form->addInput('text', 'name', '', 'Name : ', 'required=required');\n\\$form->addInput('text', 'first-name', '', 'First name : ', 'required=required');\n\\$form->addBtn('button', 'cancel', 0, 'Cancel', 'class=btn btn-warning', 'btn-group');\n\\$form->addBtn('submit', 'submit-btn', 1, 'Submit', 'class=btn btn-success', 'btn-group');\n\\$form->printBtnGroup('btn-group');" },
- { "trigger": "setAction($url, $add_get_vars = true)", "contents": "\\$form->setAction(${1:htmlspecialchars($_SERVER[\"PHP_SELF\"])}, ${2:\\$add_get_vars = true});" },
+ { "trigger": "newForm", "contents": "use phpformbuilder\\Form;\nuse phpformbuilder\\Validator\\Validator;\n\n@session_start();\ninclude_once rtrim(\\$_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/${1:phpformbuilder}/Form.php';\n/* =============================================\n validation if posted\n============================================= */\n\nif (\\$_SERVER[\"REQUEST_METHOD\"] == \"POST\" && Form::testToken('${2:my-form}') === true) {\n include_once '${1:phpformbuilder}/Validator/Validator.php';\n include_once '${1:phpformbuilder}/Validator/Exception.php';\n \\$validator = new Validator(\\$_POST);\n \\$required = array('name', 'first-name');\n foreach (\\$required as \\$required) {\n \\$validator->required()->validate(\\$required);\n }\n // check for errors\n\n if (\\$validator->hasErrors()) {\n \\$_SESSION['errors']['${2:my-form}'] = \\$validator->getAllErrors();\n } else {\n \\$from_email = '${3:you@your-email.com}';\n \\$adress = '${3:you@your-email.com}';\n \\$subject = '${4:Email Subject}';\n \\$filter_values = '${2:my-form}, submit-btn';\n \\$sent_message = Form::sendMail(\\$from_email, \\$adress, \\$subject, \\$filter_values);\n Form::clear('${2:my-form}');\n }\n}\n\\$form = new Form('${2:my-form}', 'horizontal');\n\\$form->addInput('text', 'name', '', 'Name : ', 'required=required');\n\\$form->addInput('text', 'first-name', '', 'First name : ', 'required=required');\n\\$form->addBtn('button', 'cancel', 0, 'Cancel', 'class=btn btn-warning', 'btn-group');\n\\$form->addBtn('submit', 'submit-btn', 1, 'Submit', 'class=btn btn-success', 'btn-group');\n\\$form->printBtnGroup('btn-group');" },
+ { "trigger": "setAction($url, $add_get_vars = true)", "contents": "\\$form->setAction(${1:htmlspecialchars(\\$_SERVER[\"PHP_SELF\"])}, ${2:\\$add_get_vars = true});" },
+ { "trigger": "setMethod($method)", "contents": "\\$form->setMethod(${1:\\$method});" },
{ "trigger": "addHtml($html, $element_name = '', $pos = 'after')", "contents": "\\$form->addHtml(${1:\\$html}, ${2:\\$element_name = ''}, ${3:\\$pos = 'after'});" },
{ "trigger": "addInput--function--($type, $name, $value = '', $label = '', $attr = '')", "contents": "\\$form->addInput(${1:\\$type}, ${2:\\$name}, ${3:\\$value = ''}, ${4:\\$label = ''}, ${5:\\$attr = ''});" },
{ "trigger": "addInputWrapper($html, $element_name)", "contents": "\\$form->addInputWrapper(${1:'<div class=\"wrapper\"></div>'}, ${2:'element_name'});" },
+ { "trigger": "setCols($labelsCols, $fieldsCols, $breakpoint = 'sm')", "contents": "\\$form->setCols(${1:3}, ${2:9});" },
+ { "trigger": "addIcon($input_name, $icon_html, $pos)", "contents": "\\$form->addIcon(${1:\\$input_name}, ${2:\\$icon_html}, ${3:\\$pos});" },
{ "trigger": "groupInputs($input1, $input2, $input3 = '')", "contents": "\\$form->groupInputs('${1:field_1}', '${2:field_2}');" },
{ "trigger": "addFileUpload($type, $name, $value = '', $label = '', $attr = '', $fileUpload_config = '')", "contents": "\\$fileUpload_config = array(\n 'xml' => ${1:'default'},\n 'uploader' => ${2:'defaultFileUpload.php'},\n 'btn-text' => ${3:'Browse ...'},\n 'max-number-of-files' => ${4:3}\n);\n\\$form->addHtml('<span class=\"help-block\">3 files max. Accepted File Types : .pdf, .doc[x], .xls[x], .txt</span>', ${5:\\$name}, 'after');\n\\$form->addFileUpload('file', ${5:\\$name}, ${6:\\$value = ''}, ${7:\\$label = ''}, ${8:\\$attr = ''}, \\$fileUpload_config);\n" },
{ "trigger": "addTextarea($name, $value = '', $label = '', $attr = '')", "contents": "\\$form->addTextarea(${1:\\$name}, ${2:\\$value = ''}, ${3:\\$label = ''}, ${4:\\$attr = ''});" },
@@ -33,6 +36,7 @@
{ "trigger": "FormRegisterValues($form_ID)", "contents": "Form::registerValues('${1:my-form}');" },
{ "trigger": "FormMergeValues(array('step-form-1', 'step-form-2', 'step-form-3'))", "contents": "Form::mergeValues(array('${1:step-form-1}', '${2:step-form-2}', '${3:step-form-3}'));" },
{ "trigger": "FormClear($form_ID)", "contents": "Form::clear('${1:my-form}');" },
- { "trigger": "render($debug = false)", "contents": "\\$form->render(${1:true | false});" }
+ { "trigger": "render($debug = false)", "contents": "\\$form->render(${1:true | false});" },
+ { "trigger": "FormTestToken($form_ID)", "contents": "if(Form::testToken('${1:my-form}') === true) {\n // token valid, no CSRF.\n ${2:}\n}" }
]
}
View
@@ -1,5 +1,6 @@
{
"1.0.3": "messages/1.0.3.md",
"1.0.4": "messages/1.0.4.md",
- "1.0.5": "messages/1.0.4.md"
+ "1.0.5": "messages/1.0.4.md",
+ "2.0.0": "messages/2.0.0.md"
}
View
@@ -0,0 +1,10 @@
+# Php Form Builder 2.0.0
+
+## UPDATE
+- update completions for version 2.0 :
+- add setMethod()
+- add setCols()
+- add addIcon()
+- add startDependantFields()
+- add endDependantFields()
+- add Form::testToken()

0 comments on commit 5d8cce4

Please sign in to comment.