Skip to content

Instantly share code, notes, and snippets.

@SentryXSI
Last active September 5, 2019 12:23
Show Gist options
  • Save SentryXSI/c243cb978096fcceb84ff0f1fa1f13ab to your computer and use it in GitHub Desktop.
Save SentryXSI/c243cb978096fcceb84ff0f1fa1f13ab to your computer and use it in GitHub Desktop.
Form Guard Ideas
<?php
use NinjaSentry\Katana\Form\Guard as FormGuard;
use NinjaSentry\Sai\Ui\Form\Builder as FormBuilder;
// Generator
$guard = (new FormGuard( $this->identity->session ) )
->tokens()
->lockUri( $this->route->uri )
->lockFields(
'axs_code',
FormGuard::FORM_TOKEN
);
$form = new FormBuilder( $guard );
$form->open();
$form->group()
->label('Code')
->input([
'class' => 'form-control',
'name' => $form->field('axs_code'),
'id' => 'Code',
]);
$form->group()
->hidden([
'name' => $form->field( $form->guard::FORM_TOKEN ), // Guard Key ( label )
'value' => $form->guard->csrfToken, // Guard Value
]);
$form->submit([
'class' => 'btn btn-danger',
'value' => 'Start Hard Drive Scan'
]);
$form->close();
// Validator
(new FormGuard(
$this->identity->session
))->enforce( $this->route );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment