Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for other form elements #266

Closed
ivanlanin opened this issue Jun 6, 2014 · 22 comments
Closed

Support for other form elements #266

ivanlanin opened this issue Jun 6, 2014 · 22 comments
Assignees
Milestone

Comments

@ivanlanin
Copy link
Contributor

From CodePlex. Currently we only have CheckBox.

@ivanlanin ivanlanin added this to the Later milestone Jun 6, 2014
@ozilion
Copy link
Contributor

ozilion commented Jun 9, 2014

I checked http:https://www.schemacentral.com/sc/ooxml/s-wml.xsd.html and http:https://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing.formfielddata(v=office.14).aspx but couldn't find other form element except checkbox, textbox and drop-down list. There are some aother fields but they need to be used visual basic 6 coding within developer menu.

@ivanlanin
Copy link
Contributor Author

Apparently you're right. Is it worth to develop them (textbox and dropdown element)?

@ozilion
Copy link
Contributor

ozilion commented Jun 9, 2014

TextBox is also exist, we only need to check for dropdown and i guess it'll be done in a few hours :)

@ivanlanin
Copy link
Contributor Author

The TextBox that we have is not a form element :) It's this one:

http:https://www.phpdocx.com/img/sampleScripts/WordContent/example_addTextBox_1.png

@ivanlanin
Copy link
Contributor Author

Feature added. See Sample_33_FormField.php. Travis passed. Issue closed.

@pallikiran
Copy link

Hi ivanlanin,
In Sample_33_FormField.php file using following code for dropdowns:
$textrun->addFormField('dropdown')->setEntries(array('Choice 1', 'Choice 2', 'Choice 3'));
How to set the values for those dropdown entries like HTML DROPDOWN ?

Thanks,
Kiran

@ivanlanin
Copy link
Contributor Author

Use setValue(n) with n is the index of the selected value (zero based).

$textrun->addFormField('dropdown')
    ->setEntries(array('Choice 1', 'Choice 2', 'Choice 3'))
    ->setValue(1); // select Choice 2

@pallikiran
Copy link

Thanks for your reply.
setValue(n) is for selecting the option.
But I want to set values for ->setEntries(array('Choice 1', 'Choice 2', 'Choice 3'))
Ex: 'Choice 1'=>10, 'Choice 2'=>20, 'Choice 3'=>30
suppose used setValue(1);
Then while parsing the dropdown, i want to get 20.

Is it possible?

Thakns,
Kiran

@Progi1984
Copy link
Member

@ivanlanin Could you add them in recipes ?

@pallikiran
Copy link

What i mean is :
I want to store dropdown entry values into DB instead of dropdown entries what is visible in dropdown.
->setEntries(array('Choice 1', 'Choice 2', 'Choice 3'))
by the above code 'Choice 1', 'Choice 2' and 'Choice 3' are exist in XML code.
Ex:
if i user ->setEntries(array(10=>'Choice 1', 20=>'Choice 2', 30=> 'Choice 3'))
how to store the 10, 20 and 30 in XML to retrive the selected option.
Suppose 'choice 2' is selected then 20 able to get for storing

@ivanlanin
Copy link
Contributor Author

@pallikiran The OOXML schema for w:listEntry element only allows w:val attibute. I'll see if they can accept other attribute.

@Progi1984 This info should be in the main documentation when we remove the "To be completed" statement 😄

@Progi1984
Copy link
Member

Affirmative :)

@pallikiran
Copy link

@ivanlanin... Is it possible to use w:listItem instead of w:listEntry for dropdown?

@pallikiran
Copy link

is it possible to use "w:attr" in PHPWord?

@ivanlanin
Copy link
Contributor Author

You can change line 156-158 of Writer/Word2007/Element/FormField.php into:

foreach ($entries as $key => $val) {
    $xmlWriter->writeElementBlock('w:listEntry', array('w:val' => $val, 'w:key' => $key));
}

But I don't think we will integrate this "hack" into the main PHPWord code because it's not a standard OOXML attribute.

@Progi1984
Copy link
Member

Why not create a writeComboBox method with w:listItem which supports w:value & w:displayText for each item ?

@ivanlanin
Copy link
Contributor Author

Good idea. This will open up the possibility to implement other SDT elements. @pallikiran Can you open a new issue for this? The original issue has been closed. Thanks.

@Progi1984
Copy link
Member

SDT ?

@ivanlanin
Copy link
Contributor Author

Structured document tag. w:listItem is part of SDT.

I've read about SDT but haven't found it useful until now. Perhaps it's time to support it.

@pallikiran
Copy link

Hi ivanlanin,

  1. Is it possible to set width for form textbox?
  2. Is it possible to add textboxes, CheckBox and Dropdowns to table cell for proper alignment?
    Ex: I want to add Dropdowns like 3X3 marix. i.e each cell having one dropdown box. for proper alignment.
    Please reply me asap..

Thanks,
Kiran

@ivanlanin
Copy link
Contributor Author

Hi @pallikiran,

  1. No. Currently we can't set textbox width.
  2. Yes. You can add FormField to table cell. Below is the example:
$row1 = $section->addTable()->addRow();
$row1->addCell()->addFormField('textinput')->setValue('1');
$row1->addCell()->addFormField('dropdown')->setEntries(array('Banana', 'Apple'));
$row1->addCell()->addFormField('checkbox');

$row2 = $section->addTable()->addRow();
$row2->addCell()->addFormField('textinput')->setValue('2');
$row2->addCell()->addFormField('dropdown')->setEntries(array('Linux', 'Windows', 'Mac'));
$row2->addCell()->addFormField('checkbox');

$row3 = $section->addTable()->addRow();
$row3->addCell()->addFormField('textinput')->setValue('3');
$row3->addCell()->addFormField('dropdown')->setEntries(array('PHPWord', 'PHPExcel'));
$row3->addCell()->addFormField('checkbox');

@ivanlanin
Copy link
Contributor Author

And please open a new issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants