Welcome, Guest. Please login or register.
Did you miss your activation email?
February 13, 2012, 03:35:21 AM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
149700 Posts in 21103 Topics by 7538 Members
Latest Member: ionline
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Read Only Teat Area in From  (Read 708 times)
hopper577

Offline Offline

Posts: 26


« on: April 20, 2007, 03:08:58 PM »

I want to have a read only text area in a form.  But im not sure how to do this

This is what the HTML will need to look like


Code:
<textarea name="textarea" cols="70" rows="10" readonly="readonly">Insert your read only text HERE</textarea>

Thanks

Ben
Logged
hopper577

Offline Offline

Posts: 26


« Reply #1 on: April 22, 2007, 04:11:35 AM »

Ok so I worked out how to do this for version 2.6.4.

there are three files you need to edit:
  • modules/form/modify_field.php
  • modules/form/save_field.php
  • modules/form/view.php

modify_field.php
Insert this at Line 171:
Code:
<?php if($type == 'textarea') { ?>
    <tr>
      <td><?php echo 'Read Only'?>:</td>
      <td><input type="radio" name="readonly" id="readonly_true" value='readonly="readonly"' <?php if($form['extra'] == 'readonly="readonly"') { echo ' checked'; } ?> />
        <a href="#" onclick="javascript: document.getElementById('readonly_true').checked = true;"> <?php echo $TEXT['YES'?> </a> &nbsp;
        <input type="radio" name="readonly" id="readonly_false" value="" <?php if($form['extra'] == '') { echo ' checked'; } ?> />
        <a href="#" onclick="javascript: document.getElementById('readonly_false').checked = true;"> <?php echo $TEXT['NO']; ?> </a> </td>
    </tr>
    <?php ?>

save_field.php
Insert this at line 33:
Code:
$readonly = $_POST['readonly'];

Change line 79 from:
Code:
$database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET value = '$value', extra = '' WHERE field_id = '$field_id'");

to:
Code:
$database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET value = '$value', extra = '$readonly' WHERE field_id = '$field_id'");

view.php
Line 173 from:
Code:
$values[] = '<textarea name="field'.$field_id.'" id="field'.$field_id.'" class="textarea">'.$value.'</textarea>';
To:
Code:
$values[] = '<textarea name="field'.$field_id.'" id="field'.$field_id.'" class="textarea" '.$field['extra'].'>'.$value.'</textarea>';

Thats how i done it.  I'm not sure if its the most efficient way but IT WORKS  wink

Cheers

-Ben
« Last Edit: April 22, 2007, 04:13:30 AM by hopper577 » Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!