-
☆ A M B ☆
- 1,231 Posts
I need help getting the value of a particular document. I have a form that takes the information from a pages TV and allows the front end user to edit them. I need help getting the values.
I have this for a checkbox to show it as "checked" on the front end.
[*tvBRANDDESIGN:is=`yes`:then=`checked="checked"`*]
This works if on the page that is being edited as it just edits the tv value of that document. I need to retrieve the tv values from any document. How can i use phx or the [*tvBRANDDESIGN:is=`yes`:then=`checked="checked"`*] code to include id=[[AuthorID]] for example? I hope what I want is clear.
[+phx:if:checked=checked, then id=[[GetField? etc...]]
would that work? it may be simpler to create a small snippet
don’t know if this works and this is what you need, but perhaps?
[+phx:[!getField &field=`yourtv`&docid=`yourdocid`!]:is=`yes`:then=`checked="checked"`+]
Bruno
-
☆ A M B ☆
- 1,231 Posts
Thanks for the help.
I tired the following and it’s not checking the box. This is in a form and is setup correctly, it’s just not getting the value.
<label for="tvXHTML"><span style="width:120px">XHTML</span>
<input type="checkbox" name="tvtvXHTML" id="tvXHTML"
[+phx:[[GetField? &field=`tvXHTML`&docid=`148`]]:is=`yes`:then=`checked="checked"`+] value="XHTML"/></label>
If I make the the GetField snippet uncached I get a parse error
Parse error: syntax error, unexpected ’)’ in /home/xhtmlde/public_html/assets/plugins/phx/phx.parser.class.inc.php(220) : eval()’d code on line 1
do you have to use the if: for phx?
About the error try this approach:
<input type ... checked="[+phx:...+]" ... value="XHTML" /></label>
or have the whole input inside placeholder!!
[+phx:[[GetField? &field=`tvXHTML`&docid=`148`]]:is=`yes`:then=`
<label for="tvXHTML"><span style="width:120px">XHTML</span>
<input type="checkbox" name="tvtvXHTML" id="tvXHTML"
checked="checked" value="XHTML"/></label>
`+]
Just a thought.
-
☆ A M B ☆
- 1,231 Posts
I managed to get it working
I had is=`yes` and the tv variable was actually xhtml lol. It’s worked anyway!
Please share how you put this together so I can steal it!!
-
☆ A M B ☆
- 1,231 Posts
For some reason this is not working for all fields. I have used the same method for 8 checkboxes, 7 work and 1 only partially works.
I am using this idea for the 8 boxes
<li style="float:left; width:100px; text-align:center;"><label for="tvXHTML"><span style="width:120px">XHTML</span>
<input type="checkbox" name="tvtvXHTML" id="tvXHTML"
[+phx:[[GetField? &field=`tvXHTML` &docid=`[[AuthorID]]`]]:is=`[+tvXHTML+]`:then=`checked="checked"`:else=``+] value="XHTML"/></label></li>
This shows if a TV is checked or not and allows for the value to be changed as well. However, 7 work fine and can be clicked on and off, saved etc but new options are not working. They allow me to click a checkbox and save, the value is being saved if I check the box but it will not uncheck the box after saving. I followed the same setup as the 7 fields that work.
This one doesn’t allow a checkbox to be saved unchecked
<li style="float:left; width:100px; text-align:center;"><label for="tvPRIVATE"><span style="width:120px">PRIVATE</span>
<input type="checkbox" name="tvtvPRIVATE" id="tvPRIVATE" [+phx:[[GetField? &field=`tvPRIVATE` &docid=`[[AuthorID]]`]]:is=`[+tvPRIVATE+]`:then=`checked="checked"`:else=``+] value="PRIVATE"/></label></li>
I have the TV setup with XHTML==XHTML and PRIVATE==PRIVATE respectively. It should work if I followed the same principles as the TVs that do work.
name="tvtvPRIVATE" ---> name="tvPRIVATE" ??