* Form refactoring 1

This commit is contained in:
Visman 2018-10-22 12:23:44 +07:00
parent c096d3b7d8
commit 6731167d40
2 changed files with 36 additions and 17 deletions

View file

@ -20,7 +20,6 @@ class Rules extends Page
$this->title = \ForkBB\__('Forum rules');
$this->crumbs = $this->crumbs([$this->c->Router->link('Rules'), \ForkBB\__('Forum rules')]);
$this->rules = $this->c->config->o_rules_message;
$this->formAction = null;
return $this;
}
@ -41,10 +40,41 @@ class Rules extends Page
$this->title = \ForkBB\__('Forum rules');
$this->crumbs = $this->crumbs(\ForkBB\__('Forum rules'), [$this->c->Router->link('Register'), \ForkBB\__('Register')]);
$this->rules = $this->c->config->o_rules == '1' ? $this->c->config->o_rules_message : \ForkBB\__('If no rules');
$this->formAction = $this->c->Router->link('RegisterForm');
$this->formToken = $this->c->Csrf->create('RegisterForm');
$this->formHash = $this->c->Csrf->create('Register');
$this->form = $this->formAgree();
return $this;
}
/**
* Подготавливает массив данных для формы
*
* @return array
*/
protected function formAgree()
{
return [
'action' => $this->c->Router->link('RegisterForm'),
'hidden' => [
'token' => $this->c->Csrf->create('RegisterForm'),
],
'sets' => [
'agree' => [
'fields' => [
'agree' => [
'type' => 'checkbox',
'label' => \ForkBB\__('Agree'),
'value' => $this->c->Csrf->create('Register'),
],
],
],
],
'btns' => [
'register' => [
'type' => 'submit',
'value' => \ForkBB\__('Register'),
'accesskey' => 's',
],
],
];
}
}

View file

@ -18,20 +18,9 @@
<section class="f-main f-rules">
<h2>{!! $p->title !!}</h2>
<div id="id-rules">{!! $p->rules !!}</div>
@if ($p->formAction)
@if ($form = $p->form)
<div class="f-fdiv f-lrdiv">
<form class="f-form" method="post" action="{!! $p->formAction !!}">
<input type="hidden" name="token" value="{!! $p->formToken !!}">
<fieldset>
<dl>
<dt></dt>
<dd><label class="f-child2"><input type="checkbox" name="agree" value="{!! $p->formHash !!}" tabindex="1">{!! __('Agree') !!}</label></dd>
</dl>
</fieldset>
<p class="f-btns">
<input class="f-btn" type="submit" name="register" value="{!! __('Register') !!}" tabindex="2">
</p>
</form>
@include('layouts/form')
</div>
@endif
</section>