Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

cgi::formbuilder submit button non-editable form

by chrism01 (Friar)
on Mar 04, 2008 at 01:09 UTC ( [id://671748]=perlquestion: print w/replies, xml ) Need Help??

chrism01 has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

I've got a form for deleting an item. The user supplies the record id, and I display the record fields, plus a Submit button to delete the record.
The problem is that it seems that I can only display editable fields and a Submit button, OR non-editable fields, but no Submit button.
What actually I want is non-editable fields (for obvious reasons) and a Submit button
Anyone know how?

Chris

  • Comment on cgi::formbuilder submit button non-editable form

Replies are listed 'Best First'.
Re: cgi::formbuilder submit button non-editable form
by ysth (Canon) on Mar 04, 2008 at 05:56 UTC
    I'm not a CGI::FormBuilder user, but surely people will need to see some of your code to see what might need changing?
Re: cgi::formbuilder submit button non-editable form
by quester (Vicar) on Mar 04, 2008 at 07:17 UTC
    Umm... pardon me, but non-editable fields? In a browser? Just say NO!

    In order to make the fields non-editable you have to assume things about the functionality of the user's browser. If the user gets to supply his own browser all bets are off. Imagine how you would support non-editable fields if the user connected to your server with "telnet www.victim.com 80".

    The usual solution is to establish a session state, so you can validate that hidden or non-edit fields really have the right values in them, all the fields are there, and the user didn't add anything (that matters.)

    In the case of a simple deletion, you might want to repeat whatever logic you used to determine that the user is authorized to delete this object, instead of checking the session state. That could be less code, or more, depending on how your authorization works.

      Basically, you add an empty 'readonly' attribute to the markup.

      $form->field( name => 'field_name', readonly => 1);

      For checkboxes, you can use disabled

      $form->field( name => 'choices', disabled => 'disabled');

      In response to the pedants, this is not a security issue. It is a usability question. The form is showing a different view of the same data to perform different operations on it.

      For example "make a duplicate record", or "delete record". It doesn't make sense for the user to modify those fields if the action ignores those modifications.

      The permissions handling is still managed by the server. If a user added his own query parameter in the request "&destroy_everything=1", doesn't mean the server will obey it.

Re: cgi::formbuilder submit button non-editable form
by chrism01 (Friar) on Mar 05, 2008 at 06:43 UTC
    It's just a general principle qn. The form is only for use by a small team (where I work), all techies, and on a private ip-range lan.
    Hacking is not something I'm worried about, some of them (apart from the boss) could just hack the DB anyway.
    It's a small asset mgr system, so basic forms 'cos I'm not a CGI prog, just in the job when the requirement came up.
    I'd just like for them to be able to check the details of the rec before it's deleted, but it'd be nice if the field contents were non-editable (and I'd like to know for future ref).
    OTOH, the rec id is non-editable on this form, so it's not critical.

    Chris

      Do you need a form at all?

      All you're after is a yes or no from the user. Perhaps display the data in a table and add two links

      <a href="delete.cgi?confirm=1">confirm</a> <a href="delete.cgi?confirm=0">cancel</a>
      Have the script take care of if and what is to be deleted. You really need to heed quester's note of caution about authorisation though.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://671748]
Approved by ysth
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-25 11:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found