⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠


profile picture

Default Field value that changes depending on another Field


  • profile picture
  • Member

Posted 27 November 2019 - 06:33 AM

Simply put, I need to automatically "create" a code that includes a field's value as part of a string.

This is what I currently have;

public function addsite()
        $crud = $this->_getGroceryCrudEnterprise();

        $crud->setSubject('Sites', 'Site');


        $crud->displayas('ContactName','Contact Name')
             ->displayas('ContactLastName','Contact Last Name')
             ->displayas('ContactNumber','Contact Number')
             ->displayas('ContactEmail','Contact Email')
             ->displayas('DateAdded','Date Added');


        $output = $crud->render();
        $this->_report_output($output, 'Add a Site');  

function ConString_callback()
    return 'Data Source=myserver;Initial Catalog=foodb;MultipleActiveResultSets=True;User Id=foobar;Password=123;';


What this does is automatically changes the ConnectionString field to the value generated in the ConString_callback function. Now my problem is; I need the "foodb" replaced with whatever the Name field's value is without any spaces and such. This can happen on keyup or on change, or whatever works best.

How do I proceed here?