Facebook
From Silly Treeshrew, 5 Years ago, written in Perl.
">

A PHP Error was encountered

Severity: Notice

Message: Trying to access array offset on value of type bool

Filename: view/view.php

Line Number: 33

from

A PHP Error was encountered

Severity: Notice

Message: Trying to access array offset on value of type bool

Filename: view/view.php

Line Number: 33

- view diff
Embed
Download Paste or View Raw
Hits: 230
  1. ## lib/Jizzy/Controller/Categories.pm
  2. sub edit {
  3.   my $self = shift;
  4.  
  5.   # Fetch the category id from the parameters
  6.   my $id = $self->param('id');
  7.  
  8.   # Get information from the database about the category
  9.   my $result = $self->db->resultset('Category')->find($id);
  10.   $self->param('parent_id', $result->parent_id)
  11.     unless $self->param('parent_id');
  12.  
  13.   # Add information in the stash for the template (e.g. edit.html.ep)
  14.   $self->stash(id => $result->id);
  15.  
  16.   # Render the template
  17.   $self->render;
  18. }
  19.  
  20. ## templates/categories/edit.html.ep
  21. % layout 'admin'
  22. % title => 'Jizzy.eu: Edycja Kategorii';
  23.  
  24. <h2>Category Edit [<%= stash 'id' %>]</h2>
  25.  
  26. %= form_for 'update_category' => (method => 'POST') => begin
  27.   %= include '/categories/_form'
  28.   <nav class="is-flex">
  29.     %= link_to "Back" => "/categories", class => 'button', style => "flex:1"
  30.     %= submit_button 'Update', class => 'button is-primary', style => "flex:1"
  31.   </nav>
  32. % end
  33.  
  34. ### templates/categories/_form.html.ep
  35. <table class="table is-striped is-fullwidth">
  36.   <tr>
  37.     <th><%= label_for parent_id => 'Parent:' %></th>
  38.         % my $options = category_select
  39.     <td>
  40.       %= select_field parent_id => $options, class => 'input'
  41.     </td>
  42.   </tr>
  43. </table>