×
Please submit new Bug Reports on GitHub: github.com/Jensen-Technologies/component-creator-issues/issues
Change field post value after submit
Nina
New Member
Posts: 10
4 lata 5 miesiąc temu #9745
przez Nina
Change field post value after submit was created by Nina
If I had a field called name and I wanted to ensure that the value always had uppercase on first letter of each word (ucwords) where can I change the post field value before it's saved? I want this both in frontend and backend form but after hours of Googling I still don't know where to start. Do I create a plugin, a function?
Thanks!
Thanks!
Proszę Zaloguj lub Zarejestruj się, aby dołączyć do konwersacji.
Søren Beck Jensen
Administrator
Posts: 81
4 lata 5 miesiąc temu #9746
przez Søren Beck Jensen
Søren Beck Jensen
Founder, Component-Creator.com
Replied by Søren Beck Jensen on topic Change field post value after submit
You would need to do this in the controller.
You will most likely have method called ``store() that has a variable called $data you would need to run the ucwords($data->field_name) before the data is saved.
If you paste the method from your controller I can show you in detail.
You will most likely have method called ``store() that has a variable called $data you would need to run the ucwords($data->field_name) before the data is saved.
If you paste the method from your controller I can show you in detail.
Søren Beck Jensen
Founder, Component-Creator.com
Proszę Zaloguj lub Zarejestruj się, aby dołączyć do konwersacji.
Nina
New Member
Posts: 10
4 lata 5 miesiąc temu #9747
przez Nina
Replied by Nina on topic Change field post value after submit
In backend I can'f find any method store(). Does that mean that my component are using the joomla method by default (excuse me if I'm not using the correct terms). However after googling some more I found protected function prepareTable($table) in my form model and tried this:
It seems to be working but I'm not sure if it's the correct way of doing this and I also have subform repeatable values I wish to alter and I'm not sure how to get those.
In frontend I didn't find a store() method either, only public function save($key = NULL, $urlVar = NULL) which seems to handle the storing part?
I'm grateful for your time and I'm having so much fun using the component creator and learning how to do things properly!
protected function prepareTable($table)
{
jimport('joomla.filter.output');
if (empty($table->id))
{
// Set ordering to the last item if not set
if (@$table->ordering === '')
{
$db = Factory::getDbo();
$db->setQuery('SELECT MAX(ordering) FROM #__ginv_gravvard');
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
// Always capital on first letter
$form = JFactory::getApplication()->input->get('jform', array(), 'array');
$inventerare = $form['inventerare'];
if (isset($inventerare)) {
$table->inventerare = ucwords($table->inventerare);
}
}
}
In frontend I didn't find a store() method either, only public function save($key = NULL, $urlVar = NULL) which seems to handle the storing part?
I'm grateful for your time and I'm having so much fun using the component creator and learning how to do things properly!
Proszę Zaloguj lub Zarejestruj się, aby dołączyć do konwersacji.
Emmanuel Tsalampounis
Gość
3 lata 7 miesiąc temu #9838
przez Emmanuel Tsalampounis
Replied by Emmanuel Tsalampounis on topic Change field post value after submit
Hello Nina,
If you are a premium member please open a support request here:
www.component-creator.com/en/help/contact
with your component name and your development environment to help you on that
If you are a premium member please open a support request here:
www.component-creator.com/en/help/contact
with your component name and your development environment to help you on that
Proszę Zaloguj lub Zarejestruj się, aby dołączyć do konwersacji.
Czas generowania strony: 0.056 s.