/** * Eliminar el recurso por id ó index * * @param string $route * @param mixed $resource * @param string $label * @return Callable */ function delete_resource($routeParams = [], $label = 'Eliminar') { $form = Form::open(['route' => $routeParams, 'method' => 'delete', 'class' => 'inline', 'id' => 'delete']); $form .= Form::submit($label, ['class' => 'btn btn-danger']); $form .= Form::close(); return $form; }
function delete_to_route_with_lang($params) { $form = Form::open(['route' => $params, 'method' => 'delete']); $form .= Form::submit(trans('messages.button_delete'), ['class' => 'btn btn-danger btn-sm', 'onclick' => 'return confirm("' . trans('messages.delete_confirm') . '");']); $form .= Form::close(); return $form; }
function delete_form($urlParams, $label = '削除') { $form = Form::open(['method' => 'DELETE', 'url' => $urlParams]); $form .= Form::submit($label, ['class' => 'btn btn-danger']); $form .= Form::close(); return $form; }
/** * Button generator for buttons used for @destroy actions * * @return string */ public function buttonDestroy($route, $extra) { $button = $this->open('destroy', $route, $extra); $button .= \Form::submit('Delete'); $button .= \Form::close(); return $button; }
/** * Delete form * @param $params * @param string $label * @return string */ function deleteForm($params, $label = 'Delete') { $html = Form::open(['method' => 'DELETE', 'route' => $params, 'class' => 'delete-form']); $html .= Form::submit($label, ['class' => 'btn btn-danger btn-delete']); $html .= Form::close(); return $html; }
/** * Returns resource operations for the datatables or nested sets * * @param $resource * @param $id * @param $class * @return string */ function get_ops($resource, $id, $class = "btn") { if ($class == "btn") { $show_class = "btn btn-xs bg-navy"; $edit_class = "btn btn-xs bg-olive"; $delete_class = "btn btn-xs btn-danger destroy"; } else { $show_class = "inline-show"; $edit_class = "inline-edit"; $delete_class = "inline-delete"; } $show_path = route('admin.' . $resource . '.show', ['id' => $id]); $edit_path = route('admin.' . $resource . '.edit', ['id' => $id]); $delete_path = route('admin.' . $resource . '.destroy', ['id' => $id]); $ops = '<ul class="list-inline no-margin-bottom">'; $ops .= '<li>'; $ops .= '<a class="' . $show_class . '" href="' . $show_path . '"><i class="fa fa-search"></i> ' . trans('admin.ops.show') . '</a>'; $ops .= '</li>'; $ops .= '<li>'; $ops .= '<a class="' . $edit_class . '" href="' . $edit_path . '"><i class="fa fa-pencil-square-o"></i> ' . trans('admin.ops.edit') . '</a>'; $ops .= '</li>'; $ops .= '<li>'; $ops .= Form::open(['method' => 'DELETE', 'url' => $delete_path]); $ops .= Form::submit(' ' . trans('admin.ops.delete'), ['onclick' => "return confirm('" . trans('admin.ops.confirmation') . "');", 'class' => $delete_class]); $ops .= Form::close(); $ops .= '</li>'; $ops .= '</ul>'; return $ops; }
function delete_to_route($routeName, $id) { $form = Form::open(['route' => [$routeName, $id], 'method' => 'delete']); $form .= Form::submit(Message::DELETE_BUTTON, ['class' => 'btn btn-danger', 'onclick' => 'return confirm("' . Message::DELETE_CONFIRM . '");']); $form .= Form::close(); return $form; }
public function run($static = false) { $form = new Form(); $form->post('login')->val('blank')->post('password')->val('blank'); if (!$form->submit()) { // Error $this->_error($static); return false; } $data = $form->fetch(); $login = $data['login']; $password = Hash::create('sha256', $data['password'], PASS_HASH_KEY); $query = "SELECT userid, login, role FROM user WHERE login = :login AND password = :password"; if (!($result = $this->db->select($query, array(':login' => $login, ':password' => $password)))) { $this->_error($static); return false; } Session::init(); Session::set('userid', $result[0]['userid']); Session::set('login', $result[0]['login']); Session::set('role', $result[0]['role']); Session::set('loggedIn', true); if ($static) { header('location:' . URL . 'dashboard'); } echo json_encode('success'); }
function test_submit() { $_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['HTTP_HOST'] = 'www.test.com'; $_SERVER['HTTP_REFERER'] = 'http://www.test.com/app/foo'; $form = new Form('post'); $this->assertEquals($form->method, 'post'); $this->assertEquals($form->rules, array()); $this->assertFalse($form->submit()); $this->assertEquals($form->error, 'Cross-site request forgery detected.'); $form->verify_csrf = false; $this->assertTrue($form->submit()); $_SERVER['HTTP_REFERER'] = 'http://www.other.com/foo.bar'; $this->assertFalse($form->submit()); $this->assertEquals($form->error, 'Referrer must match the host name.'); }
function delete_form($routeParams, $label = 'Delete') { $form = Form::open(['method' => 'DELETE', 'action' => $routeParams]); //dd($form); $form .= Form::submit($label, ['class' => 'btn btn-danger']); return $form .= Form::close(); }
public function display() { $form = new Form(2); $form->submit(); $GLOBALS['editinglanguage'] = new Language($_GET['language']); $table = new Table(); $token = new TableColumn("token", "Token"); $translation = new TableFunctionColumn("token", Language::DirectTranslate("TRANSLATION")); $translation->functionName = "TranslationEditor_GetString"; $translation->autoWidth = true; $languagetoken = new TableColumn("'" . DataBase::Current()->EscapeString($_GET['language']) . "' as language", "Language"); $languagetoken->value = $_GET['language']; $languagetoken->visible = false; $table->columns->add($token); $table->columns->add($translation); $table->columns->add($languagetoken); $table->name = "{'dbprefix'}language_tokens"; $table->actions = "translation_tokens"; $table->orderBy = "token"; $table->size = -1; $table->display(); $newModule = Language::DirectTranslateHtml("NEW_MODULE"); echo "<h2>" . $newModule . "</h2>"; $form->display(); }
protected function setup_form() { $form = new Petro_Form(); $form->add_model('Model_Group'); $form->add_form_action(\Form::submit('submit', 'Submit', array('class' => 'btn btn-primary'))); $form->add_form_action(\Html::anchor('groups', 'Cancel', array('class' => 'btn'))); return $form; }
/** * Display a listing of the resource. * * @return Response */ public function index() { echo Form::open(array('url' => 'l/ingreso', 'method' => 'post')); echo Form::text('username'); echo Form::text('password'); echo Form::submit('enviar'); echo Form::close(); }
/** * Form Component */ public static function formComponent() { $_templates = Themes::getTemplates(); foreach ($_templates as $template) { $templates[basename($template, '.template.php')] = basename($template, '.template.php'); } echo '<div class="col-xs-3">' . Form::open() . Form::hidden('csrf', Security::token()) . Form::label('sandbox_form_template', __('Sandbox template', 'sandbox')) . Form::select('sandbox_form_template', $templates, Option::get('sandbox_template'), array('class' => 'form-control')) . Html::br() . Form::submit('sandbox_component_save', __('Save', 'sandbox'), array('class' => 'btn btn-default')) . Form::close() . '</div>'; }
public function get_login() { echo "Hello! Welcome to the login page!"; echo Form::open('user/login', 'POST'); echo Form::text('username'); echo Form::submit('Click Me!'); echo Form::close(); }
public function get_formulario() { $variable = Form::open(['url' => '/usuarios/formulario', 'method' => 'post']); $variable .= Form::text('campo'); $variable .= Form::submit('Enviar'); $variable .= Form::close(); return $variable; }
protected function setup_form() { $form = new Petro_Form(array('class' => 'form-horizontal')); $form->add_model('Model_Client'); $form->add_form_action(\Form::submit('submit', 'Submit', array('class' => 'btn btn-primary'))); $form->add_form_action(\Html::anchor('clients', 'Cancel', array('class' => 'btn'))); // $form->sequence(array('status', '<hr/>', 'name_en', 'name', 'code')); $this->sidebars->add('New Client!', '<form action="#">' . 'Edit Client: This is the demo sidebar section inspired ' . 'by the <a href="#">ActiveAdmin</a> package for ruby' . '</form>'); return $form; }
function defaultAction() { $subjects = array(1 => array('id' => 1, 'title' => s('General question')), 2 => array('id' => 2, 'title' => s('Bug report')), 3 => array('id' => 3, 'title' => s('Collaboration or partership')), 4 => array('id' => 4, 'title' => s('Idea')), 5 => array('id' => 5, 'title' => s('Other'))); $html = ''; $errors = array(); $is_posted = request_int('is_posted'); $jump_to = 'feedback_name'; if ($is_posted) { if (!count($errors) && !request_str('email')) { $errors[] = s('Please, enter your email'); $jump_to = 'feedback_email'; } if (!count($errors) && request_str('email') && !filter_var(request_str('email'), FILTER_VALIDATE_EMAIL)) { $errors[] = s('Please, provide correct email address. For example: john@gmail.com'); $jump_to = 'feedback_email'; } if (!count($errors) && !request_str('message')) { $errors[] = s('Enter the message.'); $jump_to = 'feedback_password'; } if (!count($errors)) { $data = array('{name}' => request_str('name'), '{email}' => request_str('email'), '{subject}' => $subjects[request_int('subject_id')]['title'], '{message}' => request_str('message')); $message = str_replace(array_keys($data), array_values($data), 'Name: {name} Email: {email} Subject: {subject} {message} ' . $_SERVER['REMOTE_ADDR'] . ' ' . date('r')); core::$sql->insert(array('message' => core::$sql->s($message), 'insert_stamp' => core::$sql->i(time())), DB . 'feedback'); require_once '../mod/lib.mail.php'; foreach (array('*****@*****.**') as $email) { mail_send(request_str('name'), request_str('email'), $email, 'Metro4all.org - ' . $subjects[request_int('subject_id')]['title'], $message, false); } go(Core::$config['http_home'] . 'feedback/?action=ok'); } } $page = new PageCommon(s('Feedback')); $html .= $page->start(); $html .= '<div class="row"><div class="col-md-offset-2 col-md-8"><h2>' . s('Feedback') . '</h2>'; if (count($errors)) { $html .= '<div class="alert alert-danger"><p>' . escape($errors[0]) . '</p></div>'; } $form = new Form('feedback', false, 'post'); $html .= '<div class="well">' . $form->start() . $form->addVariable('is_posted', 1) . $form->addString('name', s('Name'), $is_posted ? request_str('name') : '') . $form->addString('email', s('E-mail'), $is_posted ? request_str('email') : '', array('is_required' => true)) . $form->addSelect('subject_id', s('Subject'), $is_posted ? request_int('subject_id') : 1, array('data' => $subjects)) . $form->addText('message', s('Message'), $is_posted ? request_str('message') : '', array('is_required' => true, 'style' => 'height:200px')) . $form->submit(s('Send')) . '</div>'; $html .= '<script> $(document).ready(function() { $("#' . $jump_to . '").focus(); }); </script>'; $html .= '</div></div>'; $html .= $page->stop(); return $html; }
public function updateSlideshow($contentID) { $form = new Form(); $form->post('animationSpeed')->val('blank')->val('digit')->post('slideDuration')->val('blank')->val('digit')->post('autoplay')->post('animationType'); if (!$form->submit()) { $error = $form->fetchError(); $this->_returnError(reset($error), key($error)); return false; } $data = $form->fetch(); // Form passed $this->db->update('slideshow', $data, '`contentID` =' . $contentID); return array('error' => false, 'results' => $data); }
public function getContent() { //@todo automate module simple configuration for Model's columns or settings (conf) if (Input::get('illuminatocomments_conf')) { $this->conf->set(['GRADES' => Input::has('enable_grades')]); $this->conf->set(['COMMENTS' => Input::has('enable_comments')]); } $html = Form::open(['id' => 'illuminatocomments_form', 'enctype' => 'multipart/form-data', 'url' => URL::full()]); $html .= Form::label('enable_grades', 'Enable grades'); $html .= Form::checkbox('enable_grades', '1', $this->conf->get('GRADES')); $html .= Form::label('enable_comments', 'Enable comments'); $html .= Form::checkbox('enable_comments', '1', $this->conf->get('COMMENTS')); $html .= Form::submit('Save', ['name' => 'illuminatocomments_conf', 'id' => 'illuminatocomments_conf']); $html .= Form::close(); return $html; }
function defaultAction() { $html = ''; $errors = array(); $is_posted = request_int('is_posted'); $jump_to = 'subscription_email'; if ($is_posted) { // $captcha_code = request_str('captcha_code'); if (!count($errors) && !request_str('email')) { $errors[] = s('Please, enter your email'); $jump_to = 'register_email'; } if (!count($errors) && request_str('email') && !filter_var(request_str('email'), FILTER_VALIDATE_EMAIL)) { $errors[] = s('Please, provide correct email address. For example: john@gmail.com'); $jump_to = 'register_email'; } // if(captcha_compare(request_str('captcha_code'))) { // captcha_close(); if (!count($errors)) { // file_put_contents('data/subscription.txt', "\r\n" . request_str('email'), FILE_APPEND | LOCK_EX); core::$sql->insert(array('email' => core::$sql->s(request_str('email')), 'insert_stamp' => core::$sql->i(time())), DB . 'subscription'); /* switch (request_int('language_id')) { case 1: mail('*****@*****.**', 'subscribe gisconf '.request_str('email'), '*password: Oov4eeph', 'From: news@gisconf.ru'); break; case 2: mail('*****@*****.**', 'subscribe gisconf-en '.request_str('email'), '*password: Oov4eeph', 'From: news-en@gisconf.ru'); break; } */ go(core::$config['http_home'] . 'subscription/?action=ok'); } // } // else // $errors []= 'Неверный код подтверждения'; } $page = new PageCommon(s('Newsletter')); $html .= $page->start(); $html .= '<div class="row"><div class="col-md-offset-1 col-md-6"><h1>' . s('Newsletter') . '</h1>'; if (count($errors)) { $html .= '<div class="alert alert-danger"><p>' . escape($errors[0]) . '</p></div>'; } $form = new Form('subscription', false, 'post'); $html .= '<div class="well">' . $form->start() . $form->addVariable('is_posted', 1) . $form->addString('email', s('E-mail'), $is_posted ? request_str('email') : '', array('is_required' => true)) . $form->submit(s('Subscribe')) . '</div>'; $html .= '<script> $(document).ready(function() { $("#' . $jump_to . '").focus(); }); </script>'; $html .= '</div></div>'; $html .= $page->stop(); return $html; }
function email() { try { $l_oValidator = new Form(); $l_oValidator->post('signUpEmail'); $l_oValidator->val('notEmpty'); $l_oValidator->val('isEmail'); $l_oValidator->submit(); } catch (arrayException $e) { $l_sError = $e->getResults(); } if (isset($l_sError['signUpEmail'])) { $this->view->emailError = $l_sError['signUpEmail']; } else { $this->model->signUp($_POST['signUpEmail']); $this->view->emailSuccess = "Signup successful"; } }
public function editNavLink($contentID) { // Validate $form = new Form(); $form->post('name')->val('blank')->post('url')->val('blank'); if (!$form->submit()) { // Error $error = $form->fetchError(); $this->_returnError(reset($error), key($error)); return false; } $data = $form->fetch(); // Form passed // Update Content DB Entry $this->db->update('content', array('url' => $data['url']), "`contentID` = " . $contentID); $this->db->update('navLink', array('name' => $data['name']), "`contentID` = " . $contentID); echo json_encode(array('error' => false)); }
public function display() { $form = new Form(1); $form->submit(); $table = new Table(); $token = new TableColumn("token", "Token"); $token->autoWidth = true; $name = new TableColumn("name", Language::DirectTranslate("NAME")); $table->columns->add($token); $table->columns->add($name); $table->name = "{'dbprefix'}languages"; $table->actions = "translations"; $table->orderBy = "name"; $table->display(); $newTranslation = Language::DirectTranslateHtml("NEW_TRANSLATION"); echo "<h2>" . $newTranslation . "</h2>"; $form->display(); }
public function index_prefix($searchTerm) { $structure = $this->structure; $create_url = action($structure['controller'] . '@create'); $this->html = ' <div class="row"> <div class="col-md-12"> <h2>' . $structure['title'] . '</h2> </div> </div> <div class="row"> <div class="col-md-12"> <div class="block-web col-md-12">'; $this->html .= \Form::open(array('method' => 'get')); $this->html .= '<div class="row">'; $this->html .= '<div class="col-sm-10">' . \Form::text('search', $searchTerm, array('required', 'class' => 'form-control parsley-validated', 'required', 'parsley-min' => '1', 'placeholder' => 'Search In Items')) . '</div>'; $this->html .= '<div class="col-sm-2">' . \Form::submit('Search', array('class' => 'control-label btn btn-primary')) . '</div>'; $this->html .= '</div>'; $this->html .= \Form::close(); $this->html .= ' </div> </div> </div> <div class="row mitter"> <div class="col-md-12"> <div class="block-web"> <div class="header"> <h3 class="content-header">All ' . str_plural($structure['title']) . '</h3> </div> <div class="porlets-content"> <div class="adv-table editable-table "> <div class="clearfix"> <div class="btn-group"> <a href="' . $create_url . '" class="btn btn-primary"> Add New <i class="fa fa-plus"></i> </a> </div> </div> <div class="margin-top-10"></div>'; }
/** * Retorna a instancia do formulario com os campos * @param \Model $Model Model para insercao no db (ou falso) * @param string $Action Acao do formulario * @param array $FormFields Campos pra montar o form * @param Nome do controlador $ControllerName * @return string */ public function getForm($Model = false, $Action, $FormFields, $ControllerName) { $this->Module = $ControllerName; $this->Model = $Model; if ($Model) { $this->Model = $Model; // Abre o form com os campos preenchidos $data['head'] = \Form::model($Model, array('url' => $Action, 'class' => 'form-horizontal col-md-12')); } else { // Abre o form padrao $data['head'] = \Form::open(array('url' => $Action, 'class' => 'form-horizontal col-md-12')); } // $data = []; foreach ($FormFields as $field_name => $field_config) { // Monta o label, adicionando um "*" se o campo for requerido // $label = \Form::label($field_config['name'],($this->Module.".{$field_config['name']}.form")); $translation = trans($this->Module . ".{$field_config['name']}.form") . (isset($field_config['required']) && $field_config['required'] ? '*' : ''); if (isset($field_config['trans'])) { $translation = $field_config['trans']; } // Monta a label $label = \Form::label($field_config['name'], $translation); // Monta o field $field = $this->input($field_config); // mdd([$label, $field]); // Formata o label // $label_format = \Html::tag('div', $label->toHtml(), ['class' => 'col-md-3']); // Formata o field // $field_format = \Html::tag('div', $field->toHtml(), ['class' => 'col-md-9']); // Adiciona os items no elemento principal // $data[$field_name] = \Html::tag('div', $label_format.$field_format, ['class' => 'form-group col-md-12']); $data['fields'][$field_name]['label'] = $label; $data['fields'][$field_name]['field'] = $field; // mdd($data[$field_name]); } // Botao de enviar $data['submit'] = \Form::submit(trans($this->Module . '.button_save'), ['class' => 'btn btn-success']); // Fecha o form $data['foot'] = \Form::close(); // mdd($data); return $data; }
echo Form::selectRange('numOfUsers', 1, 20, $n) . " "; echo Form::label('lNumOfUsers', 'Number of Users'); echo '<br><br>'; isset($request->birthdate) ? $selected = true : ($selected = false); echo Form::checkbox('birthdate', 'birthdate', $selected); echo Form::label('lBirthdate', 'Birthdate'); echo '<br>'; isset($request->address) ? $selected = true : ($selected = false); echo Form::checkbox('address', 'address', $selected); echo Form::label('lAddress', 'Address'); echo '<br>'; isset($request->profile) ? $selected = true : ($selected = false); echo Form::checkbox('profile', 'profile', $selected); echo Form::label('lProfile', 'Profile'); echo '<br><br>'; echo Form::submit('Submit'); ?> {!! Form::close() !!} <p> @if(isset($users)) @foreach($users as $user) <h3> {{ $user->name }} </h3> <?php if (isset($request->birthdate)) { echo '   <b>Birthdate: </b>' . $user->date($format = 'Y-m-d', $max = "now"); echo '<br>'; } ?> {!! isset($request->address) ? '   <b>Address:</b> ' . $user->address . '<br>' : '' !!}
<?php HTML::macro('discussion', function ($discussion, $article_id, $level) { $result = '<div class="discussion-main col-xs-12 ' . ($level < 5 ? 'commentary-new-level' : 'x') . '"> <div class="discussion-commentary row"> <div class="col-xs-3">' . HTML::profilePicture($discussion->user, '100%', '100%', ['class' => 'discussion-profile col-xs-3']) . '</div> <div class="col-xs-9 discussion-right"> <span class="discussion-author-info">' . link_to_action('UserController@getProfile', $discussion->user->fullname, ['user_id' => $discussion->user->slug]) . ' <a class="discussion-date"> ' . $discussion->created_at . ' </a></span> <p>' . $discussion->text . '</p> </div>'; if (Auth::check()) { $result .= '<div class="col-xs-12 discussion-bottom"> <span class="reply-link pull-right"> <a onclick="resizeArea(' . $discussion->id . ')" name="reply">Odpovedať</a>'; if (Auth::user()->hasRole(\App\Models\User::ADMIN_ROLE) || Auth::user()->hasRole(\App\Models\User::TEACHER_ROLE)) { $result .= '<br> <a href="' . action('DiscussionController@getDelete', ['id' => $discussion->id]) . '" style="color:red">Zmazať nevhodný komentár</a>'; } $result .= '</span>' . Form::open(['url' => action('DiscussionController@postAddDiscussion'), 'method' => 'post']) . Form::hidden('parent', $discussion->id) . Form::hidden('article_id', $article_id) . '<textarea id="' . $discussion->id . '" class="reply" style="" name="text"></textarea><br>' . Form::submit('Odoslať', ['class' => 'btn btn-ba-style hidden-btn ' . $discussion->id, 'name' => 'action']) . Form::close() . '</div>'; } $children = \App\Models\Discussion::where('parent', '=', $discussion->id)->orderBy('created_at', 'ASC')->get(); foreach ($children as $child) { $result .= HTML::discussion($child, $article_id, $level + 1); } $result .= '</div> </div>'; return $result; });
$not_yet[$guest->name] = $guest; } } ksort($arrived); ksort($not_yet); ?> <div class="content-primary"> <?php echo Form::open('mobile/search'); ?> <?php echo Form::input('query', isset($query) ? $query : '', array('type' => 'search', 'placeholder' => 'guest name', 'required' => 'required')); ?> <?php echo Form::submit('', 'Search'); ?> <?php echo Form::close(); ?> <ul data-role="listview" data-divider-theme="b" data-inset="true"> <?php if (count($not_yet)) { ?> <li data-role="list-divider">Waiting</li> <?php foreach ($not_yet as $name => $guest) { ?> <li> <?php
?> <form method="post"> <p> <label for="which"><?php echo __('Select a :element', array(':element' => __(ucfirst($element->type())))); ?> </label> <?php $choices = $element->select_list($element->pk()); echo Form::select('element', $choices, $element->id); ?> </p> <p> <?php echo Form::submit('submit', __('Save Changes'), array('class' => 'submit')); ?> <?php echo html::anchor(Route::get('kohanut-admin')->uri(array('controller' => 'pages', 'action' => 'edit', 'params' => $page)), __('cancel')); ?> </p> </form> </div> </div> </div>