Textpattern Forum

You are not logged in. Register | Login | Help

#61 2011-05-06 22:26:14

milosevic
Member
From: Madrid, Spain
Registered: 2005-09-19
Posts: 345

Re: mem_simple_form

hablablow dijo:

Ahhh vielen Dank Jakob ! It’s working…

<txp:mem_simple_form table="smd_bio" id_field="user_ref" id_insert="0">
<txp:mem_form_text name="table_country" label="Country" break="" />
<txp:mem_form_secret name="int_user_ref" value="{userA}" />
<txp:mem_form_submit />
</txp:mem_simple_form>

Just a minor bug: It’s updating all users: userA, userB (?!)… I’m not sure why… Is this related to the way I use the call above ? Or the way smd_bio is built ?

I found the solution!

<txp:mem_form_secret name="int_user_ref" value="{userA}" />

Note that user_ref field at smd_bio table is NOT an integer, it is a string value, so you have to code that line this way:

<txp:mem_form_secret name="string_user_ref" value="{userA}" />

And them everythink works fine and you will only update de userA data.

Last edited by milosevic (2011-05-06 22:26:45)


<txp:rocks/>

Offline

#62 2011-05-07 07:23:16

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: mem_simple_form

I will try this Jorge… Thank you very much for sharing !


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#63 2011-05-10 15:15:46

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: mem_simple_form

And it’s working Jorge, muchas gracias !

Do you have any idea on how to empty a value ?
I’m stuck with that one for quite some time…

By empty I mean remove the value of a field, press save and so it removes the value from the db ?
Currently I can only replace a value, not delete it…
When I remove a value from a field and hit the save button, the page reloads but the value is still there

:(

Any idea ?

Last edited by hablablow (2011-05-10 15:18:15)


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#64 2011-05-10 15:57:04

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 1,918
Website

Re: mem_simple_form

By empty I mean remove the value of a field, press save and so it removes the value from the db ?
Currently I can only replace a value, not delete it…
When I remove a value from a field and hit the save button, the page reloads but the value is still there

Guillaume, is that specifically related to checkboxes? IIRC an unchecked checkbox is not submitted as a POST variable so it’s not processed. I think the trick in this case is to use mem_form_hidden to preset the value to zero, then use mem_form_checkbox with the same name after it to override it so you end up with something like this:

<input type="hidden" name="the_checkbox" value="0" />
<input type="checkbox" name="the_checkbox" value="1" />

Does that help?


TXP Builders – finely-crafted code, design and txp

Offline

#65 2011-05-10 19:40:42

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: mem_simple_form

Jakob, nein das ist nicht ein checkbox sonder ein simple text input field…
Once it’s filled with a value, I can only replace it with another value…
If I just empty the field and hit the save button, once the page is reloaded, I still have the value there…

I just can’t empty a simple text field from what is already recorded in the db…

Should I then preset every input, especially text inputs, contained in my form with a zero value before the input itself ?

Is that a decent way to go ???

Last edited by hablablow (2011-05-10 19:47:06)


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#66 2011-05-11 09:55:57

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: mem_simple_form

Nope, it’s not working

:(

Here’s the detail of my form:

<txp:mem_simple_form table="smd_bio" id_field="user_ref" id_insert="0">
<txp:mem_form_hidden name="table_docname" label="" value="" />
<txp:mem_form_text name="table_docname" label="Download doc. name" max="200" size="25" break="" required="0" default='<txp:smd_bio_info items="docname" itemclass="" author="SMD_PRIVS:2" break="" label="" wraptag=""/>' />
<txp:mem_form_secret name="string_user_ref" value='<txp:smd_bio_info items="name" label="" itemclass="" author="SMD_PRIVS:2" break="" label="" wraptag=""/>' />
<txp:mem_form_submit />
</txp:mem_simple_form>

… … …


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#67 2011-05-15 10:07:37

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 1,918
Website

Re: mem_simple_form

Hi Guillaume,

You’re right, it doesn’t seem to reset any fields if you delete a field. I tried this in an smd_tabber window and it seemed to work, at least from my limited testing:

<txp:variable name="logged-in-user" value='<txp:php>global $txp_user; echo htmlspecialchars($txp_user);</txp:php>' />

<h3><txp:rah_function call="get_author_name"><txp:variable name="logged-in-user" /></txp:rah_function></h3>

<txp:smd_query table="smd_bio" column="*" where="user_ref='?logged-in-user'">
<txp:mem_simple_form table="smd_bio" id_field="user_ref" id_insert="0">
<txp:mem_form_secret name="string_user_ref" value="{user_ref}" />
  <ul>
    <li><txp:mem_form_secret name="string_biography" value="" />
        <txp:mem_form_textarea name="string_biography" label="Biography" required="0">{biography}</txp:mem_form_textarea></li>
    <li><txp:mem_form_secret name="string_website" value="" />
        <txp:mem_form_text name="string_website" label="Website" break="" default="{website}" required="0" /></li>
    <li><txp:mem_form_submit button="1" label="Save" /></li>
  </ul>
</txp:mem_simple_form>

</txp:smd_query>

It’s a bit cumbersome with all those mem_form_secrets but seems to do the job. Probably this is something that Manfre needs to tackle – that, or we’ve both missed something fundamental.


TXP Builders – finely-crafted code, design and txp

Offline

#68 2011-05-15 11:24:26

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: mem_simple_form

Vielen dank Jakob, I should try this and thanks for sharing… And yes, this doesn’t seem simple unless we miss something obvious…


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#69 2011-05-18 20:41:35

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: mem_simple_form

Ach vieeeeeelen dank Jakob it’s fully working now ! :))
Ho boy, You made my day !
Take care !


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#70 2011-05-19 21:12:14

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 1,918
Website

Re: mem_simple_form

Great! I experimented a little more and was able to replicate most of the functionality provided by smd_bio for admin users, including the picture-switcher, in a little dashboard:


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB