public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null, $Title = '', BootstrapModalFormAction $ModalFormAction) { parent::__construct($controller, $name, $fields, $actions, $validator, $Title, $ModalFormAction); Requirements::block('BootstrapModalForm_hasErrorJs_' . $this->FormName()); Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-form/jquery.form.js'); $name = $this->FormName(); $action = $this->FormAction(); $loading = _t('BootstrapAjaxModalForm.LOADING', 'BootstrapAjaxModalForm.LOADING'); $js = <<<JS (function(\$){ \$(function(){ \$('#{$name}').ajaxForm({ delegation: true, target: '#Modal_{$name} .modal-dialog .modal-content', beforeSubmit: function(data, form, options){ \$('#{$name} [type=submit]').prop("disabled", true).html('{$loading}'); } \t}); }); \$(function(){ \$('#Modal_{$name}').on('show.bs.modal', function(e){ \$('#Modal_{$name} .modal-dialog .modal-content').load('{$action}'); }); \$('#Modal_{$name}').on('hidden.bs.modal', function(e){ \$('#Modal_{$name} .modal-dialog .modal-content').html(''); }); }); })(jQuery); JS; Requirements::customScript($js, 'BootstrapAjaxModalForm_Js_' . $this->FormName()); if (Director::is_ajax()) { $this->setTemplate('BootstrapAjaxModalForm'); } }
public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null, $Title = '', BootstrapModalFormAction $ModalFormAction) { parent::__construct($controller, $name, $fields, $actions, $validator, $Title, $ModalFormAction); Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js'); Requirements::javascript('bootstrap_extra_fields/javascript/tooltip.js'); $this->setTemplate('BootstrapHorizontalModalForm')->addExtraClass('form-horizontal')->setLarge(); }