EllisLab text mark
Advanced Search
     
anchor(), scaffolding error
Posted: 21 October 2007 06:43 AM   [ Ignore ]
Joined: 2007-10-20
1 posts

Hi,
  Just started using CI - very nice :)
A totally default installation gives a warning of:

A PHP Error was encountered
Severity: Warning
Message: preg_match() expects parameter 2 to be string, array given
Filename: helpers/url_helper.php
Line Number: 93

when using the scaffolding. 
Tracking back through the code I see the ‘view’ model in scaffolding uses :

<?php echo anchor(array($base_uri, ‘edit’, $row->$primary), $scaff_edit); ?>

Would it be useful to add 2 lines of code into the anchor() function in the URI helper as follows:

function anchor($uri = ‘’, $title = ‘’, $attributes = ‘’)
{
    if (is_array($uri))
      $uri=implode(’‘,$uri); //—EDIT—:- or perhaps I meant implode on ‘/’ !  I think I probably did :)
....  existing code ...
}

This would stop the warning message.  I don’t know if this would affect the code in ways I haven’t thought about though !

Regards