Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (41 sloc) 8.7 KB
{
"scope": "source.php -variable.other.php",
"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\" && 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 = ''});" },
{ "trigger": "addOption($select_name, $value, $txt, $group_name = '', $attr = '')", "contents": "\\$form->addOption(${1:\\$select_name}, ${2:\\$value}, ${3:\\$txt}, ${4:\\$group_name = ''}, ${5:\\$attr = ''});" },
{ "trigger": "addSelect($select_name, $label = '', $attr = '', $displayGroupLabels = true)", "contents": "\\$form->addSelect(${1:\\$select_name}, ${2:\\$label}, ${3:\\$attr = ''}, ${4:\\$displayGroupLabels = true});" },
{ "trigger": "addCountrySelect($select_name, $label = '', $attr = '', $user_options = array())", "contents": "\\$form->addCountrySelect('${1:country}', '${2:Country : }');" },
{ "trigger": "addRadio($group_name, $label, $value, $attr)", "contents": "\\$form->addRadio(${1:\\$group_name}, ${2:\\$label}, ${3:\\$value}, ${4:\\$attr = ''});" },
{ "trigger": "printRadioGroup($group_name, $label = '', $inline = true, $attr = '')", "contents": "\\$form->printRadioGroup(${1:\\$group_name}, ${2:\\$label}, ${3:\\$inline = true}, ${4:\\$attr = ''});" },
{ "trigger": "addCheckbox($group_name, $label, $value, $attr)", "contents": "\\$form->addCheckbox(${1:\\$group_name}, ${2:\\$label}, ${3:\\$value}, ${4:\\$attr});" },
{ "trigger": "printCheckboxGroup($group_name, $label = '', $inline = true, $attr = '')", "contents": "\\$form->printCheckboxGroup(${1:\\$group_name}, ${2:\\$label}, ${3:\\$inline = true}, ${4:\\$attr = ''});" },
{ "trigger": "addBtn($type, $name, $value, $text, $attr = '', $btnGroupName = '')", "contents": "\\$form->addBtn(${1:\\$type}, ${2:\\$name}, ${3:\\$value}, ${4:\\$text}, ${5:\\$attr = ''}, ${6:\\$btnGroupName = ''});" },
{ "trigger": "printBtnGroup($btnGroupName, $label = '')", "contents": "\\$form->printBtnGroup(${1:\\$btnGroupName}, ${2:\\$label = ''});" },
{ "trigger": "startFieldset($legend = '')", "contents": "\\$form->startFieldset(${1:\\$legend = ''});" },
{ "trigger": "endFieldset()", "contents": "\\$form->endFieldset();" },
{ "trigger": "startDependantFields()", "contents": "\\$form->startDependantFields(${1:\\$parent_field}, ${2:\\$show_values});" },
{ "trigger": "endDependantFields()", "contents": "\\$form->endDependantFields();" },
{ "trigger": "addPlugin($plugin_name, $selector, $js_content = 'default', $js_replacements = '')", "contents": "\\$form->addPlugin(${1:\\$plugin_name}, ${2:'#selector'}, ${3:\\$js_content = 'default'}, ${4:\\$js_replacements = ''});" },
{ "trigger": "printIncludes($type)", "contents": "\\$form->printIncludes('${1:js | css}');" },
{ "trigger": "printJsCode()", "contents": "\\$form->printJsCode();" },
{ "trigger": "FormSendMail($from_email, $adress, $subject, $filter_values = '', $values = '')", "contents": "\\$from_email = '${1:you@your-email.com}';\n\\$adress = '${2:recipient@email.com}';\n\\$subject = '${3:Email Subject}';\n\\$filter_values = '${4:my-form, submit-btn}';\n\\$sent_message = Form::sendMail(\\$from_email, \\$adress, \\$subject, \\$filter_values);" },
{ "trigger": "FormSendAdvancedMail($options, $values = '')", "contents": "\\$options = array(\n 'from_email' => '${1:you@your-email.com}',\n 'from_name' => '${2:phpformbuilder}', // optional\n 'reply_to' => '${3:you@your-email.com}', // optional\n 'adress' => '${4:john.doe@gmail.com}',\n 'cc' => '${5:john.doe@free.fr}', // optional\n 'bcc' => '${6:john.doe@hotmail.com, john.doe@wanadoo.com}', // optional\n 'subject' => '${7:contact from phpformbuilder}',\n 'attachments' => '${8:img/wallacegromit.jpg}', // optional\n 'html_template' => '${9:../mailer/email-templates/contact-email.html}', // optional\n 'css_template' => '${10:../mailer/email-templates/contact-email.css'}, // optional\n 'filter_values' => '${11:}', // optional\n 'sent_message' => '${12:<p class=\"alert alert-success\">Your message has been successfully sent !</p>}', // optional\n 'display_errors' => ${13:true} // optional, default false\n );\n \\$sent_message = Form::sendAdvancedMail(\\$options);\n" },
{ "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": "FormTestToken($form_ID)", "contents": "if(Form::testToken('${1:my-form}') === true) {\n // token valid, no CSRF.\n ${2:}\n}" }
]
}