I have a SQL Database where the users can create a ticket then update the ticket if need be. This all works and the user can view the updated field in the , but what I would to achieve is to display the newly updated field in a different textarea field but not be able to edit it and only edit a new textarea field. Once saved and the user needs to update it again it needs to then display the 2 uneditable textfields and display new textfield to update.
Here is my code what i have at the moment:
<div class="form-group col-lg-12 col-md-12 col-sm-12 <?php echo (!empty($description_err)) ? 'has-error' : ''; ?>">
<label>Description</label>
<textarea name="descriptionfield" class="form-control" required="required" placeholder="Enter Description"><?php echo $description; ?></textarea>
</div>
So with this code I can update and delete but only displays in the same textarea.
Can someone point me in the right direction to achieve this?
Hoping what I explained makes sense.
Thanks
Something like the below image
So you are only able to update and delete a textarea but you want to show the original one and a new empty text area after they submit, then if they update that one, the original one and second one show all while allowing a new textfield to be there?
You aren't creating the text-boxes, submitting queries, and fetching results in a way the allows you to do that.
What you need to do is:
In your general application you will need 2 things, the empty text area field for the which you already have. An empty div area where you could display the old text areas.
In your database you need to add another table because you you will basically be joining these child text area updates updates. new table: textareachildren.
When somebody submits a ticket, that text area information should go into your first table where the info is going which is already happening. Now I'm assuming your table for those posts has a primary ID correct? so lets say we just put a ticket in and the ID is 1. Here is where #Padmanabhan is trying to find out, when the ticket is submitted the page is refreshed correct? and it shows that ticket they just submitted?
Now they want to edit that ticket's text area, I assume you already are pulling in the ticket by it's ID. Since you said they could already edit/update but it just shows the value they submitted. It looks by your picture that theres a note added and new note section. OK so thats good, so within that function where they could update the ticket text area field, a few important things need to happen. Once they click update, you need to run a sql query to input this new textarea value into the textareachildren table. within that table there should be 3 columns, the primary ID of the new items in there, the value of the textarea field, and third the important the connecting_ID which is the same value of the ID of the original ticket ID. this is how they will be connected and you could display those historical text areas.
Now go back to your original query that displays the ticket when they first submit, in there you need to also query by joining the the original ticket id with the connecting_ID of the new child textarea. The query will say ah yes, I am pulling this textarea value from the other table because my connecting_ID is 1 and it matches my 'parents' so I know I belong to them. Then just display that in the html within a new text area field that does not have the option to update/edit, since its probably a for loop for all those children that you want to show, you could add in the HTML textarea disabled readonly attributes, and even add classes to it so its like grayed out or something that shows you can't edit.
So to summarize every time somebody updates the text field you aren't changing that original value since you want to display that, you just add this new child textarea field value in a new table, when you query to show those old values to you just join them and display those historical textareas how ever you want.
Related
I am using ACF repeater field for user profiles, which shows like this in the user profile page:
That's cool.
But on the front-end I have a form that I want to use to delete a specific row. My custom form simply lists all the rows with radio buttons, and so if the user selected number 3 and submitted the form then I want to delete the third row (in this example, the row with Catherine Davies would be deleted).
The form works fine in that it submits as expected and returns the value the user selected, but my code to delete the row that was selected doesn't seem to work.
The ACF documentation seems a little vague on the subject. Based on a combination of the ACF doc and this StackOverflow post, I expect this code to work but it does not:
$user_ID = get_current_user_id();
$field = 'extra_user_info'; // Name of the repeater field
$row_to_delete = $_POST["row_to_delete"];
delete_sub_row($field, $row_to_delete, 'user_' . $user_id);
Just to be sure, even if I hardcode the $row_to_delete variable to any number (from 1 to 4) it still does not delete any row.
Just to clarify, I wish to delete an entire row.
Note: I realise I could just embed the ACF form on the front-end, but for reasons I won't go into this is not an option, hence using my own custom form.
There could be another issue but in your example at least, your $user_ID variable has capital letters, while the variable passed to delete_sub_row() is lowercase. PHP variables are case-sensitive.
I have a search form that the user uses to find persons from the database, the results are displayed on a table, then the user can choose persons from the results table and add them or remove them from another table (the CGridView) and this last table will be saved to the database when the user clicks save button. My problem is that I'm adding and removing the persons (the rows) with jQuery, so when I use the sort function of the CGridView, clicking any header, the rows that were added with jQuery are lost. Also, when I remove rows from the last table I want to refresh the table so the zebra style rearranges. How can I do this without losing the data added with jQuery?
I am trying to figure out the thought process behind the following. From a list of records displayed on the screen (php/mysql, each item will have a combo box or command button to "save to favorites". I would prefer the combobox, but beggers can't be choosers. This saved to favorites is a tab that list those items from the combo box or command button.
Make a table and copy the item number into that table and under the "saved to favorites" display those records? I guess another combobox on each listing to clear it from my favorites???
Did I just answer my own question? Could it be that easy???
Possibly,
If I understand you right, you could populate an item and it's item value.
Then submit this item number and user_value from a session maybe into a row in a new table, possibly favourites?
Would that work for you?
Unique key in your DB
unique index(user, item);
I want to edit/update, multiple rows together in Yii CGridView.
Say, each row has a checkbox and a single edit/update button, I select multiple rows and by clicking on edit/update button all selected rows are opened for editing and update.
Is this possible with Yii CGridView..??
Use the selectableRows property of the CGridView.
According to Yii Documentation for CGridView
public integer $selectableRows;
the number of table body rows that can be selected. If 0, it means rows cannot be selected. If 1, only one row can be selected. If 2 or any other number, it means multiple rows can be selected. A selected row will have a CSS class named 'selected'.
You can use the the $.fn.yiiGridView.getSelection(containerID) to retrieve the key values of the selected rows.
Add some more buttons either at the top or bottom of the gridview with actions for edit, delete or whatever action you need to take and pass the key values retrieved above.
If you want to edit rows in-line you can use extension phaActiveColumn which I messed up to support multiple rows (the whole table if desired).
EDIT: well, the extension basically creates an input field replacing the grid cell when user clicks on the cell. The field will have the cell's value for starters and it then sends an ajax call to controller, as soon as the user presses enter, asking to save the value of the field, which will be the user's input.
My addition was to create one such field for every cell in the row and store user input in javascript objects which then get send all at once with one ajax call to the controller. Multiple row updates are supported (creating adequate number of javascript objetcs).
If anyone has any interest in this there it is.
phaEditColumn2
phaAbsActiveColumn2
I currently have a PHP form that uses AJAX to connect to MySQL and display records matching a user's selection (AJAX: Display MySQL data with value from multiple select boxes)
As well as displaying the data, I also place an 'Edit' button next to each result which displays a form where the data can be edited. My problem is editing unique records since currently I only use the selected values for 'name' and 'age' to find the record. If two (or more) records share the same name and age, I am only able to edit the first result.
Let's assume your file for editing is edit.php. Then, in the file where you generate the edit links, try changing your edit button link as follows:
'edit'
Then you will be able to access ID variable as
echo $_REQUEST['ID'];
Note that the ID is case sensitive. Let me know how it goes.
when displaying records from ajax, also send the primary field(id in most cases) along with name and age
and when u are displaying these data along with edit incorporate that primary field with edit