Re: Update 4 [message #945 is a reply to message #944] |
Wed, 11 July 2007 13:46 |
AJM
Messages: 2371 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
I have just tried multiple selections with my MULTI4, and the selection string which is created contains those multiple selections. You must have something wrong in your code.
Step through with your debugger, particulary at lines 180 and 181 in the childform() function in file 'include.session.inc' as this is where the contents of $fieldarray is turned into a string based on which rows were selected.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
|
Re: Update 4 [message #949 is a reply to message #948] |
Thu, 12 July 2007 09:28 |
AJM
Messages: 2371 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
That is by design, actually. The $where_array in _cm_pre_getData() only shows values from the first selected row so that it is easy to determine which field names have been specified, and there is no need to duplicate the same field name for every row as they are all the same (just with different values).
In your case it would be better to extract the value for 'sel_publish_key' in the _cm_initialise() method as it will be filtered out of the $where string in the code which follows (provided that 'sel_publish_key' has not been manually inserted into the $fieldspec array). You can do it with code such as:
function _cm_initialise ($where)
{
$where_array = where2array($where);
$this->sel_publish_key = $where_array['sel_publish_key'];
return $where;
} // _cm_initialise
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
Re: Update 4 [message #952 is a reply to message #950] |
Thu, 12 July 2007 10:51 |
AJM
Messages: 2371 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
Surely you only need the first occurrence as the value for 'sel_publish_key' is the same for every occurrence? There is only a single value available on the previous MULTI4 function.
The reason that 'sel_publish_key' is not being filtered out of the $where string is that it is contained within the $fieldspec array, presumably because of code within the _cm_changeConfig() method. This addition is necessary in the MULTI4 function, but not in the UPDATE4 function.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
|
|
Re: Update 4 [message #957 is a reply to message #956] |
Thu, 12 July 2007 14:59 |
AJM
Messages: 2371 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
If you look at the comment before that line you will see that I am looking for multiple words, and '\b' is supposed to test for a word boundary. It returns false with a fieldname of 'foobar' but true if it contains '_' (underscore) as in 'sel_publish_key'. If you change to preg_match('/\w+ \w+/', $fieldname) you should find that it solves the problem.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: Update 4 [message #959 is a reply to message #958] |
Fri, 13 July 2007 12:11 |
AJM
Messages: 2371 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
When you press a navigation button without selecting any entries the framework will create a selection string using the $where cause which went into the database object. In this case it will be the inner entity of the MULTI4. Because this selection string is not empty it will not be rejected by the UPDATE4 controller, so you will need code in your database object to inspect the $where string for validity before being allowed to continue.
The best place to do this would be the _cm_initialise method. If the $where string is invalid simply put an error message into $this->errors[] and the UPDATE4 controller will terminate and return to the MULTI4.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|