Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthorsuthern
    • CommentTimeApr 17th 2008 edited
     

    Sorry for the alarming title, but I think there is definitely something a little odd going on here. I think the form helper is trying to look up object details when it shouldn't. Here is the setup.

    My controller fetches 'parts_orders' table and creates an array called $this->parts_orders. The simple array looks like this:

    Array
    ( [0] => Array
        (   [id] => 40
            [TxnLineID] =>
            <snip other fields>
        )
      [1] => Array
        (   [id] => 48
            [TxnLineID] =>
            <snip other fields>
     ) )
    

    Here is a simplified cutout of my view:

    {loop parts_orders}
      <?php echo $form_helper->hidden_field('parts_orders',$i.'__id',array('value' => @$parts_order['id'] )); ?>
      <?php // echo $form_helper->hidden_field('parts_orders',$i.'__TxnLineID',array('value' => @$parts_order['TxnLineID'] )); ?>
      // lots of other hidden fields and stuff
    {end}
    

    Here's the odd behavior. The page runs fine as shown above, But as soon as I uncomment the 2nd line, the page 'crashes' with this error:

    Call to a member function get() on a non-object in /home/sambaserve/web/akelos/lib/AkActionView/helpers/form_helper.php on line 468

    First off, why is it calling object->get()? 'parts_order' is NOT an object in this case, but a simple array, thus we should not be treating it as an object.
    Secondly, why is it crashing on the 2nd line at all? That field is a perfectly valid array key, just like the ['id'] above it, but yet ['TxnLineID'] crashes the script.
    Thirdly, if I enter an INVALID key name (like 'booger' or 'yahoo') instead of 'id' or 'TxnLineID', I get the same error. I'm not sure if this is related but they do look like close cousins. Shouldn't the @ symbol cause PHP to ignore any errors that particular variable creates?

    Can someone shed some light on this subject? I'm a little confused. (like normal)

    Thanks!

    • CommentAuthorThijs
    • CommentTimeApr 18th 2008 edited
     

    I think the FormHelpers only take objects. That's what it says in the API docs.

    I guess you’ll have to use a FormTagHelper in this case.

    • CommentAuthorsuthern
    • CommentTimeApr 18th 2008
     

    It's the inconsistent behavior that I'm worried about. It tries to call $parts_orders->get('TxnLineID') and fails, but why dosen't it tell me that I can't do ->get('id') or ->get('Quantity), or any of the other keys that I use?

    Why does it fail on only TxnLineID? That's my main concern. Also, if the 2nd argument in hidden_field() is supposed to be the name of the column, then every single one of my lines should produce the error. No columns have names like '1__id' or '1__Quantity' or '2__id' or '2__Quantity', but yet, they all work fine except for '$i__TxnLineID'. I'll dig a bit deeper when I get the chance.

Add your comments
    Username Password
  • Format comments as