Solved: Use {shortlang} in Autofill map

Status
Not open for further replies.

keianrad

Member
Is it possible to use {shortlang} in map field of the autofill plugin like below to fill data based on the site language?

Code:
{"app_guidance_docs___{shortlang}":"app_documents___guideline"}

There is a form that it needs to shows document guide based on dropdown element's selection and site language. the problem that is, the guide is a multilingual and it needs to autofill based on the site language.
 
did you try?

Gesendet von meinem SM-G930F mit Tapatalk

Try what? I tried these codes but didn't work.
Code:
{"app_guidance_docs___{shortlang}":"app_documents___guideline"}
Code:
{"app_guidance_docs___.{shortlang}":"app_documents___guideline"}
 
That won't currently work.

Try this. Edit plugins/fabrik_form/autofill/autofill.php, and around lines 206 to 233, replace the existing code for the fillField() function with this:

Code:
protected function fillField($data, &$newData, $from, $to)
{
   $w       = new FabrikWorker;
   $to      = $w->parseMessageForPlaceHolder($to, $data);
   $matched = false;
   $toRaw   = $to . '_raw';
   $fromRaw = $from . '_raw';

   if (array_key_exists($from, $data))
   {
      $matched = true;
   }

   $newData->$to = isset($data->$from) ? $data->$from : '';

   if (array_key_exists($fromRaw, $data))
   {
      $matched = true;
   }

   if (!$matched)
   {
      $newData->$toRaw = $newData->$to = $w->parseMessageForPlaceHolder($from, $data);
   }
   else
   {
      $newData->$toRaw = isset($data->$fromRaw) ? $data->$fromRaw : '';
   }
}

That should work.

Let me know. If it works I'll commit that change to github.

-- hugh
 
Thank you for your reply. I replaced the code and tried with both codes listed below in auto fill map but it didn't work.

Code:
{"app_guidance_docs___{shortlang}":"app_documents___guideline"}

with this code it shows the field name



Code:
{"app_guidance_docs___.{shortlang}":"app_documents___guideline"}

with this code it doesn't show anything.



That won't currently work.

Try this. Edit plugins/fabrik_form/autofill/autofill.php, and around lines 206 to 233, replace the existing code for the fillField() function with this:

Code:
protected function fillField($data, &$newData, $from, $to)
{
   $w       = new FabrikWorker;
   $to      = $w->parseMessageForPlaceHolder($to, $data);
   $matched = false;
   $toRaw   = $to . '_raw';
   $fromRaw = $from . '_raw';

   if (array_key_exists($from, $data))
   {
      $matched = true;
   }

   $newData->$to = isset($data->$from) ? $data->$from : '';

   if (array_key_exists($fromRaw, $data))
   {
      $matched = true;
   }

   if (!$matched)
   {
      $newData->$toRaw = $newData->$to = $w->parseMessageForPlaceHolder($from, $data);
   }
   else
   {
      $newData->$toRaw = isset($data->$fromRaw) ? $data->$fromRaw : '';
   }
}

That should work.

Let me know. If it works I'll commit that change to github.

-- hugh
 

Attachments

  • fabrikar.jpg
    fabrikar.jpg
    34.8 KB · Views: 347
Last edited:
Hello,
I updated fabrikar to the latest version. it seems that this issue that already solved has been returned again and the change doesn't support with the latest version.

Would you please check it again.

Thanks
 

Attachments

  • fab.jpg
    fab.jpg
    34.8 KB · Views: 146
Last edited:
When you say "updated", do you mean through the J! extension manager?

If so, you probably need to re-apply a full github, as I don't think there's been a release since that change was made.

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top