Skip to content

Instantly share code, notes, and snippets.

@jjn1056
Last active August 5, 2024 13:35
Show Gist options
  • Save jjn1056/e7f7f29441d8be7a658b62c198cbe85b to your computer and use it in GitHub Desktop.
Save jjn1056/e7f7f29441d8be7a658b62c198cbe85b to your computer and use it in GitHub Desktop.
package Example::Web::Controller::TodoList;
use Moose;
use Example::Syntax;
use Modulo::PageController; # to get attributes, etc
has 'people' => (is=>'rw', context=>1);
has 'person' => (is=>'rw');
sub page($class, $page) {
$page->form('person', sub ($f) {
$f->input_text('first_name')
->input_text('last_name')
->radio_buttons('employment_id', sub ($r) {
$r->append_button('retired');
})
->submit(sub ($s, $self, $c, $body) {
$self->person
->first_name($boby->first_name)
->last_name($body->last_name)
->update;
});
});
}
<m:formFor m:id='person'>
<div class='form-group'>
<m:input_group type='text' m:name='first_name'>
</div>
<div class='form-group'>
<m:label m:name='first_name'>
<m:input type='text'>
<m:errors_for>
<m:unorderList m:list="${messages}" m:item="message">
<m:listItem m:content="${message}" />
</ul>
</m:errors_for>
</m:label>
<m:input type='text' m:name='first_name'>
</div>
</m:form>
package Example::Web::Controller::TodoList;
use Moose;
use Example::Syntax;
use Modulo::PageController; # to get attributes, etc
with 'Modulo::Actions::DBIC::CRUD'
has 'people' => (is=>'rw', context=>1);
has 'person' => (is=>'rw');
sub page :At('todo/list') Get Post Patch Delete ($class, $page) {
$page->form('person', sub ($f) {
$f->input_text('first_name')
->input_text('last_name')
->radio_buttons('employment_id', sub ($r) {
$r->append_button('retired');
})
->submit(\&create_or_update);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment