chris.paschen
Chris Paschen
I'm trying to create a php validation on an element. (a name element that I need to make sure that the name being entered isn't already used). However, during editing, I need to run the validation but NOT fail for editing the existing record.
The element I'm validating is 'name_pen'.
Which I get via:
$selectedPenName = $data;
I'm doing this via a query:
However, I'm having trouble getting the 'id' value for the record that I'm presently validating (for the 2nd WHERE clause).
What is the proper (most reliable) way to get the value of another field in the current row being edited (during validation)?
I found another forum post that led me to something like this:
But that doesn't seem to work.
I couldn't find anything in the wiki that specifically addressed this (although I wasn't 100% sure what to search on).
If you can point me to a page on the wiki that provides definitive methods of getting values in this situation that would be very helpful.
The element I'm validating is 'name_pen'.
Which I get via:
$selectedPenName = $data;
I'm doing this via a query:
$query
->select($db->quoteName('name_pen'))
->from($db->quoteName('ked_books_author_profile'))
->where($db->quoteName('name_pen') . " COLLATE UTF8_GENERAL_CI LIKE '".$selectedPenName."'",'AND')
->where($db->quoteName('id') . " != " . $currentPenNameID);
->select($db->quoteName('name_pen'))
->from($db->quoteName('ked_books_author_profile'))
->where($db->quoteName('name_pen') . " COLLATE UTF8_GENERAL_CI LIKE '".$selectedPenName."'",'AND')
->where($db->quoteName('id') . " != " . $currentPenNameID);
However, I'm having trouble getting the 'id' value for the record that I'm presently validating (for the 2nd WHERE clause).
What is the proper (most reliable) way to get the value of another field in the current row being edited (during validation)?
I found another forum post that led me to something like this:
$app = JFactory::getApplication();
$model = $this->getModel();
$currentPenNameID = (int) $this->user->get('id');
$model = $this->getModel();
$currentPenNameID = (int) $this->user->get('id');
But that doesn't seem to work.
I couldn't find anything in the wiki that specifically addressed this (although I wasn't 100% sure what to search on).
If you can point me to a page on the wiki that provides definitive methods of getting values in this situation that would be very helpful.