⚠ 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

Simply get value of one column id form edit area



oak

oak
  • profile picture
  • Member

Posted 14 April 2018 - 12:01 PM

Hello,

 

i am really so many hours on this problem, please give a hint.

 

$crud->columns(['oid', 'pid', 'usern', 'form', 'operationtitle', 'timestamp', 'deleted']);

 

$crud->callbackEditField('form', function ($fieldValue, $primaryKeyValue) {
    return '<input class="form-control" name="formula" value="' . $fieldValue . '"  />
            <br>verf&uuml;gbar (Formel '.$primaryKeyValue.') '.PID??.'<br>
            <iframe name="iframe" src="/change_query.php?projectid='.$primaryKeyValue.'&username='.$_SESSION["username"].'" height="120" width="450" frameborder="0" style="font-family:Arial;border:1px solid #c0c0c0"></iframe>
            ';
});

 

i have to load externela content in this edit view but therefore i need the PID. How can i get this PID in file as standalone value?

 

Thank you so much.

 

Regards,

Olaf

 


web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 15 April 2018 - 08:17 AM

Hello Olaf,

 

You can add this line of code to get the data for your callbackEditField:

 

$rowData = $this->db->where('your-id', $primaryKeyValue)->get('your-tablename')->row();

More specifically for your example you can have something like this:

 

$crud->callbackEditField('form', function ($fieldValue, $primaryKeyValue) {
	$rowData = $this->db->where('id', $primaryKeyValue)->get('users')->row();

	$pid = $rowData->PID;

    return '<input class="form-control" name="formula" value="' . $fieldValue . '"  />
            <br>verf&uuml;gbar (Formel '.$primaryKeyValue.') '.PID??.'<br>
            <iframe name="iframe" src="/change_query.php?projectid='.$primaryKeyValue.'&username='.$_SESSION["username"].'" height="120" width="450" frameborder="0" style="font-family:Arial;border:1px solid #c0c0c0"></iframe>
            ';
});

As your question is valid that this should work without a work-around at the next version (2.5.4)

I will include the form data as a 3rd parameter to the callback just like grocery CRUD community. Till then you should use it with the above work-around

Regards

Johnny
 


oak

oak
  • profile picture
  • Member

Posted 17 April 2018 - 09:55 AM

ok thank you...


web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 22 April 2018 - 16:58 PM

Hello @oak,

 

I would like to inform that the latest version (2.5.4) is now fixing the issue that you had, so you can simply get the full row data as a 3rd parameter to your callback. More specifically you can do this:
 

$crud->callbackEditField('form', function ($fieldValue, $primaryKeyValue, $rowData) {
	$pid = $rowData->PID;

    return '<input class="form-control" name="formula" value="' . $fieldValue . '"  />
            <br>verf&uuml;gbar (Formel '.$primaryKeyValue.') '.PID??.'<br>
            <iframe name="iframe" src="/change_query.php?projectid='.$primaryKeyValue.'&username='.$_SESSION["username"].'" height="120" width="450" frameborder="0" style="font-family:Arial;border:1px solid #c0c0c0"></iframe>
            ';
});