示例#1
0
 public function _registrationForm()
 {
     $card = html::card();
     $card->header(lucid::$app->i18n()->translate('navigation:authentication.view.registration'));
     $card->block()->add(html::form('regform', '#!authentication.controller.process'));
     $form = $card->lastChild()->lastChild();
     $form->add(html::row());
     list($left, $right) = $form->lastChild()->grid([12, 12, 6], [12, 12, 6]);
     $left->add(html::formGroup(lucid::$app->i18n()->translate('model:users:email'), html::input('email', 'email')->preAddon('@')));
     $left->add(html::formGroup(lucid::$app->i18n()->translate('model:users:password'), html::input('password', 'password')->preAddon(html::icon('lock'))));
     $right->add(html::formGroup(lucid::$app->i18n()->translate('model:users:first_name'), html::input('text', 'first_name')));
     $right->add(html::formGroup(lucid::$app->i18n()->translate('model:users:last_name'), html::input('text', 'last_name')));
     $form->add(html::submit(lucid::$app->i18n()->translate('button:register'))->pull('right'));
     $this->ruleset('register')->send($form->name);
     return $card;
 }
示例#2
0
 public function renderNoDataMessage()
 {
     $row = html::row();
     $row->add(html::td()->colspan(count($this->children)));
     $row->lastChild()->add(html::alert('warning', $this->msgDataNoFoundTitle, $this->msgDataNotFoundBody));
     return $row->render();
 }
示例#3
0
 public function edit(int $org_id)
 {
     # By default, require that the user be logged in to access the edit form. If you want additional
     # permissions, use the lucid::$app->$security->requirePermission() function.
     #lucid::$app->permission()->requireLogin();
     # lucid::$app->$security->requirePermission('organizations-select');
     # Set the title tag for the page. Optionally, you can also set the description or keywords meta tag
     # by calling lucid::$app->$response->description() or lucid::$app->$response->keywords()
     lucid::$app->response()->title(lucid::$app->i18n()->translate('branding:app_name') . ' - Organizations');
     # Render the navigation controller.
     lucid::$app->factory()->view('navigation')->render('organizations.view.table', 'organizations.view.edit');
     # Load the model. If $org_id == 0, then the model's ->create method will be called.
     $data = $this->controller()->getOne($org_id);
     # the ->notFound method will throw an error if the first parameter === false, which will be the case
     # if the model function is passed an ID that is not zero, but is not able to retrieve a row for that ID
     #lucid::$app->$error->notFound($data, '#body');
     # Based on whether or not the primary key for the model == 0, the header message will either be the dictionary
     # key form:edit_new or form::edit_existing.
     $headerMsg = lucid::$app->i18n()->translate('form:edit_' . ($data->org_id == 0 ? 'new' : 'existing'), ['type' => 'organizations', 'name' => $data->name]);
     # Construct the form and retrieve the ruleset for the controller. You can have multiple functions in your
     # controller if you want to have that controller accept submissions from different forms with different numbers
     # of fields, but the auto-generated ruleset-returning function is simply called ->ruleset(). The ->send()
     # method of the ruleset object packages up the rules into json, and sends them to the client so that they can be
     # used clientside when the form submits.
     $form = html::form('organizations-edit', '#!organizations.controller.save');
     $this->ruleset('edit')->send($form->name);
     $role_id_options = lucid::$app->factory()->model('roles')->select('role_id', 'value')->select('name', 'label')->order_by_asc('name')->find_array();
     $role_id_options = array_merge([0, ''], $role_id_options);
     # create the main structure for the form
     $card = html::card();
     $card->header()->add($headerMsg);
     $card->block()->add([html::formGroup(lucid::$app->i18n()->translate('model:organizations:role_id'), html::select('role_id', $data->role_id, $role_id_options)), html::formGroup(lucid::$app->i18n()->translate('model:organizations:name'), html::input('text', 'name', $data->name)), html::formGroup(lucid::$app->i18n()->translate('model:organizations:is_enabled'), html::input('checkbox', 'is_enabled', $data->is_enabled)), html::formGroup(lucid::$app->i18n()->translate('model:organizations:created_on'), html::input('date', 'created_on', (new \DateTime($data->created_on))->format('Y-m-d H:i'))), html::input('hidden', 'org_id', $data->org_id)]);
     $card->footer()->add(html::formButtons());
     $form->add($card);
     $layout = html::row();
     list($left, $right) = $layout->grid([12, 12, 6, 6, 6], [12, 12, 6, 6, 6]);
     $left->add($form);
     $right->add(lucid::$app->factory()->view('addresses')->_table($org_id));
     lucid::$app->response()->replace('#main-fullwidth', $layout->render());
 }