Hi,
You need to use options_my_product_**********
Where ********** is equal to the Attribute code of the Extrafield
Hi,
You need to use options_my_product_**********
Where ********** is equal to the Attribute code of the Extrafield
Hi,
Just tried and dident work.
Can you tell me if my code is corect
// Loop on each lines
for ($i = 0; $i < $nblines; $i++)
{
if ($object->lines[$i]->fk_product)
{
require_once (DOL_DOCUMENT_ROOT."/product/class/product.class.php");
$product = new Product($this->db);
$product->fetch($object->lines[$i]->fk_product);
$extrafields_product = new ExtraFields($this->db);
$extralabels_product = $extrafields_product->fetch_name_optionals_label($product->table_element);
$product->fetch_optionals($product->rowid, $extralabels_product);
}
$outputlangs->convToOutputCharset($product->array_options['options_my_product_letnik']);
$object->lines[$i]->fetch_optionals($object->lines[$i]->rowid,$extralabelsline);
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
// Define size of image if we need it
Hi i made the atribut title to load but not the atribute.
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("Prevozeni",":")." ".$outputlangs->convToOutputCharset($product->array_options['options_product_prevozeni'],"km"), 0, 'L', 0);
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($product->array_options['options_my_product_letnik']), 0, 'L', 0);
$posYAfterDescription = $pdf->GetY();
Hi,
Sorry I was too quick,
You need to use options_**********
Where ********** is equal to the Attribute code of the Extrafield
One more thing what about pick field so it wont show 1 for first item
Hi,
What is a “pick field” ?
I ment select list
my appologies
I done that and on creatig PDF i get 500 error
Made it like that
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("Številka šasije")."".(":")." ".$extrafields->showOutputField('my_extra', $object->array_options['options_stevilka_sasije']), 0, 'L', 0);
Hi,
Need to replace
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("Številka šasije")."".(":")." ".$extrafields->showOutputField('my_extra', $object->array_options['options_stevilka_sasije']), 0, 'L', 0);
by
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("Številka šasije")."".(":")." ".$extrafields->showOutputField('stevilka_sasije', $object->array_options['options_stevilka_sasije']), 0, 'L', 0);
Still get 500 error
dose have to be $object->array_options or $product->array_options
Tried bouth and dont work
Hi,
Depends where you have created the “stevilka_sasije” extrafield
Tried and still get 500 error
What Error ?
Give details please
Hi,
Thanks for the solutions but i decidet to do with text field insted of select list field
https://wiki.dolibarr.org/index.php/Add_Extrafields_on_PDF_Models
Is good for extrafield in PDF ok.
But for select list, PROBLEM.
I have had to comment momentarily, the line that gives me error (PDF crash)
$object->fetch($rowid);
$object->fetch_optionals($rowid,$extralabels);
$extrafields = new ExtraFields($db);
// $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$pdf->MultiCell(0, 3, 'LISTA: '.$outputlangs->convToOutputCharset($object->array_options['options_lista']), 0, 'L', 0);
LISTA: 2
AND
$pdf->MultiCell(0, 3, 'LISTA: '.$extrafields->showOutputField('lista', $object->array_options['options_lista']), 0, 'L', 0);
not possible with the ($extralabels=$extrafields->fetch_…) // commented
Please HELP!
Hi,
What error ?
What is the extra field configuration ?
Can you share the full model ?
With line
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
Answer:
What error? => crash PDF, HTTP ERROR 500
What is the extra field configuration ? => facture (facture_cust_extrafields.php) / Select lis:
1,lista1
2,lista2
3,lista3
Can you share the full model ? => (pdf_crabe.modules.php)
}
}
// EXTRAFIELD test Select list *******************************
$object->fetch($rowid);
$object->fetch_optionals($rowid,$extralabels);
$extrafields = new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$pdf->MultiCell(0, 3, 'LISTA: '.$outputlangs->convToOutputCharset($object->array_options['options_lista']), 0, 'L', 0);
// $pdf->MultiCell(0, 3, 'LISTA: '.$extrafields->showOutputField(‘lista’, $object->array_options[‘options_lista’]), 0, ‘L’, 0);
//*******************************
// Display notes
$notetoshow = empty($object->note_public) ? '' : $object->note_public;
With code:
// EXTRAFIELD test Select list *******************************
$object->fetch($rowid);
$object->fetch_optionals($rowid,$extralabels);
$extrafields = new ExtraFields($db);
// $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$pdf->MultiCell(0, 3, 'LISTA: '.$outputlangs->convToOutputCharset($object->array_options['options_lista']), 0, 'L', 0);
// $pdf->MultiCell(0, 3, 'LISTA: '.$extrafields->showOutputField('lista', $object->array_options['options_lista']), 0, 'L', 0);
//*******************************
Momentarily I have solved, modifying the options in the selection list
lista1, lista1
lista2, lista2
lista3, lista3
So the result in pdf is
LISTA: lista2
[image]
Could you check the logs to see what is the error ?