⚠ 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 forum is read-only and soon will be archived. ⚠


Default Field value that changes depending on another Field

grocery crud enterprise javascript php

  • Please log in to reply
No replies to this topic

#1 ChrisCross

ChrisCross

    Newbie

  • Members
  • Pip
  • 2 posts

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->setTable('Companies');
        $crud->setSubject('Sites', 'Site');

        $crud->columns(array('Name','ContactName','ContactLastName','ContactNumber','ContactEmail','DateAdded'));

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

        $crud->callbackaddfield('ConnectionString',array($this,'ConString_callback'));
        $crud->readOnlyFields(array('ConnectionString'));

        $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?







Also tagged with one or more of these keywords: grocery crud enterprise, javascript, php

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users