Go to main content

Textpattern CMS support 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: 390

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
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,192
Website GitHub

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
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,192
Website GitHub

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
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,192
Website GitHub

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

#71 2011-05-19 21:23:11

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

Re: mem_simple_form

Jakob, is the above using smd_tabber or something else?

Offline

#72 2011-05-20 06:12:11

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

Re: mem_simple_form

How cool and good looking !
I was able to implement it using the jmd_dashboard in a same fashion to build an about tab with options.
smd_bio adds an extra layer of great possibilities to Txp.
Again thanks Jakob for sharing your experience.


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

Hablablow + Webdesignofficina

Offline

#73 2011-05-20 08:17:08

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

Re: mem_simple_form

John, if you are on a pre txp 4.4 version and would like to achieve the same as Jakob did, ie without using smd_tabber, look at this post

The post explains also how to pull data from smd_bio.

Last edited by hablablow (2011-05-20 08:17:58)


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

Hablablow + Webdesignofficina

Offline

#74 2011-05-20 08:27:38

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,192
Website GitHub

Re: mem_simple_form

Yes, that was with smd_tabber but in the past I’ve also used jmd_dashboard. The select drop-down is constructed with normal txp-tags (i.e. not a mem-form element) using txp:images and txp:image_info, and a bit of jquery detects when you change it and carries the value over into the mem_form input box with the image number and displays the relevant image.

The only thing I wasn’t so hot on after making all that was that normally a success message shows and no form and you have to reload the tab to get your form back. To force the page to reload showing the form with the new changes incorporate, put the following in your success form:

<txp:php>header("Location: ".$_SERVER['HTTP_REFERER']);</txp:php>

A further nicety would be to put up a message via textpattern’s announce() (or pagetop) function (the message that appears in the header) signalling that the changes have been incorporated. Stef has given me a tip but I’ve yet to try it out:

Best way is probably via a little plugin. Raise a callback on the event=admin_side, step=pagetop and try altering the value of $message if you detect a mem_form submission on the current page event.

If either of you happen to get something like that working, I’d be most grateful for some info.


TXP Builders – finely-crafted code, design and txp

Offline

#75 2011-09-15 09:17:57

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

Re: mem_simple_form

Hi

Had someone used this plugin to upload images to textpatern?

I succeeded to post article into textpattern table using it, but now i need to upload images also!

I found the mem_form_file, but it s made for file, i see in mem_moderation_image code that it s used to upload image, but i havent understund how it did, and which arguments to put or maybe it needs additional code??

Thanks if someone can explain or give an example.

Offline

Board footer

Powered by FluxBB