I'm trying to create a Custom Field in SugarOS 6 to store Middle Names. Designing and implementing the field in EditView was easy enough with the Studio. But I'm stuck when it comes to displaying the concatenated name parts in DetailView (i.e. Salutation + First Name + Middle Name + Last Name).
Foraging through the Sugar Forums got me to this thread which describes a way it can be done. I've implemented the code given there in the form of a Sugar logic hook that utilizes the after_retrieve hook that is called upon the loading of a record.
Here's my hook code:
$hook_array['after_retrieve'] = Array();
$hook_array['after_retrieve'][] = array(
100,
'set_full_name',
'custom/modules/Leads/leads_custom_logic.php',
'LeadsCustomLogic',
'setFullName'
);
And here's the function that is being called:
function setFullName( &$focus, $event, $arguments ) {
$name = $focus->salutation . ' ' .
$focus->first_name . ' ' .
( $focus->middle_name_c ? ( $focus->middle_name_c . ' ' ) : '' ) .
$focus->last_name;
$focus->name = $name;
$focus->full_name = $name;
// echo $focus->full_name;
}
The hook and the called code seems to work fine and if I uncomment the last line (echo) the full name is dumped all over the screen (wherever this function is called). However, it's not displaying where it's actually supposed to, i.e. the row in the DetailView screen where the full name appears.
Any ideas?
Thanks,
m^e
maybe just change detailview.php and add the following to your full name field defs
'customCode' => '{$fields.salutation.value} {$fields.first_name.value} {$fields.midle_name_c.value} {$fields.last_name.value}'
as a new key => value in array and the custom code will be displayed instead of full_name value.
Related
I am testing some network packets of my Organisation's product. We already have custom plugins. I am trying to add some some more fields into those existing plugins (like conversion of 2 byte code to a string and assign it to a field)
Thankyou in advance for reading my query.
--edit
Wireshark version : 2.4.5 (organization's plugins dont work on latest wireshark application)
--edit
Problem statement:
I am able to add field and show value, but fieldname is not displayed as defined.
I cannot share the entire .lua file but i will try to explain What i did:
Below is the image where I have a field aprint.type. this is a two byte field. In .lua file, for display purpose it is appended with corresponding description using a custom function int_to_enum.
I want to add one more proto field aprint.typetext which will show the text.
What I did:
Added a protofield f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text") (Tried f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text",FT_STRING) also)
Below the code where subtree aprint.type is shown, added my required field as subtree:add(f_apr_msg_type_txt, msg_type_string) (Below is image of code extract)
I am able to see the text but field Name is shown as Wireshark Lua text (_ws.lua.text)
Normally displaying strings based on numeric values is accomplished by a value string lookup, so you'd have something like so:
local aprint_type_vals = {
[1] = "Foo",
[2] = "Bar",
[9] = "State alarm"
}
f_apr_msg_type = ProtoField.uint16("aprint.type", "Type", base.DEC, aprint_type_vals)
f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text", base.ASCII)
... then
local msg_type = tvb(offset, 2):le_uint()
subtree:add_le(f_apr_msg_type, tvb(offset, 2))
subtree:add(f_apr_msg_type_txt, tvb(offset, 2), (aprint_type_vals[msg_type] or "Unknown"))
--[[
Alternatively:
subtree:add(f_apr_msg_type_txt, tvb(offset, 2)):set_text("aprint_type_text: " .. (aprint_type_vals[msg_type] or "Unknown"))
--]]
I'm also not sure why you need the extra field with only the text when the text is already displayed with the existing field, but that's basically how you'd do it.
I'm use Visual Basic 6 to create a table with many Textbox which named txtNo1, txtNo2, txtNo3,...
I want to use the "For...Next..." loop to assign a content to these Textbox.
How can I call all these Textbox in the simplest way?
For i = 1 to 100
txtNo (......) .txt = "ABC"
Next i
Instead of using unique textboxes, each with a unique name, you should use a (textbox) control array:
Place the 1st textbox on the form, name it 'txtNo'
Copy it and paste it onto the form
VB will ask you "There's already a control named 'txtNo'. Would you like to create a control array?". Answer "Yes"
Paste as the textbox as many times as you need it
Then your code looks like
' Control arrays typically start at index 0
For i = 0 to 100
txtNo(i) .txt = "ABC"
Next i
Jim Mack's solution works as well, code for it:
' Assuming your form is named 'Form1'
For each ctrl in Form1.Controls
If TypeOf ctrl Is Textbox
For i = 1 To 100
If ctrl.Name = "txtNo" & CStr(i) Then
ctrl.Text = "ABC"
End If
End If
End If
It's a bit more complex, but therefore more flexible as works with multiple control types (in one loop).
If you need an easiest way to create your textboxes as a table, you can Load the controls at runtime. You have to add only the first TextBox control to your form, set the name to "txtNo", and Index to 0 in the Properties window.
In your code, call Load() to create additional controls, and you can set the Top/Left and other properties
For i = 1 To 100
Load txtNo(i)
txtNo(i).Top = txtNo(i - 1).Top + txtNo(i - 1).Height + 150
txtNo(i).Left = txtNo(i - 1).Left
txtNo(i).Text = "Textbox " & i
txtNo(i).Visible = True
Next i
If you need again to change any control property, from your list of controls, you can iterate only over your control list, instead of all controls of your Form
For i = txtNo.LBound() To txtNo.UBound()
Form1.Controls("txtNo")(i).Text = "New text " & i
Next i
I have an edit form which has an image field where a user can upload a new image if he wants to.
But if the user does not upload a new photo I want to just use the photo that's already in the database. And not update the image field at all. But in my code whenever I am trying to without uploading new image form is not taking the old input value.
Here is my edit function:
public function expenseupdate1(){
$input = Input::only('id','Expense_date','Expense_category_id','Vendor_id','Customer_id','Amount','Tax1_id','Tax2_id','Note','Receipt');
$data=new Expense;
$id=$input['id'];
$Expense_date=$input['Expense_date'];
$Expense_category_id=$input['Expense_category_id'];
$Vendor_id=$input['Vendor_id'];
$Customer_id=$input['Customer_id'];
$Amount=$input['Amount'];
$Tax1_id=$input['Tax1_id'];
$Tax2_id=$input['Tax2_id'];
$Note=$input['Note'];
if(Input::hasFile('Receipt')) {
$file = Input::file('Receipt');
$name = time() . '-' . $file->getClientOriginalName();
$data->Receipt = $name;
$file->move(public_path() . '/images/', $name);
}
$affectedrows=Expense::where('id', '=', $id)->update(array('Expense_date' => $Expense_date,'Expense_category_id'=>$Expense_category_id,'Vendor_id'=>$Vendor_id,'Customer_id'=>$Customer_id,'Amount'=>$Amount,'Tax1_id'=>$Tax1_id,'Tax2_id'=>$Tax2_id,'Note'=>$Note,'Receipt'=>$Receipt));
return redirect('expenseinfo');
}
and here is my update form image field code:
<td> <div class="form-group"style="margin-left:-305px">
{!! Form::label('image', 'Receipt') !!}
<input Input::old('Receipt'), type="file" name="Receipt" value = '{{$data->Receipt}}'></td><td><?php echo $data->Receipt; ?></td>
</div></td>
<tr>
<td>{!! Form::submit('Update', array( 'class'=>'' )) !!}
{!! Form::close() !!}</td>
Any help would be appreciated greatly
You wouldn't set a default value for file.
The file input type creates a field
through which users can upload files
from their local computer or network.
The VALUE attribute specifies the name
of the initial file, but it is
typically ignored by browsers as a
security precaution.
So, your application is behaving correctly. Since the image is already in the database you wouldn't need to uploaded it again.
Also, just FYI but you can clean up your controller method dramatically!
/**
* Update Expense 1
*
* #param Request $request
* #return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function expenseupdate1(Request $request){
$expense = Expense::find($request->input('id'));
$expense->fill($request->only('id','Expense_date','Expense_category_id','Vendor_id','Customer_id','Amount','Tax1_id','Tax2_id','Note','Receipt'));
if($request->hasFile('Receipt')) {
$file = $request->file('Receipt');
$name = time() . '-' . $file->getClientOriginalName();
$expense->Receipt = $name;
$file->move(public_path('/images/'), $name);
}
$expense->save();
return redirect('expenseinfo');
}
The above assumes you have the necessary use statements at the top of you're controller i.e.
use Illuminate\Http\Request;
use App\Expense; //Assuming that Expense is in this namespace
If you haven't already, you should set the fillable array for you model to allow the fill() method (mass assignment) to work http://laravel.com/docs/5.1/eloquent#mass-assignment
There is even more you can do but I have already gone outside the scope of this question. I would, however, suggest looking at:
http://laravel.com/docs/5.1/routing#route-model-binding
http://laravel.com/docs/5.1/controllers#restful-resource-controllers
http://laravel.com/docs/5.1/controllers#dependency-injection-and-controllers
Hope this helps!
I started new thread.
I have weird problem with program whose source i can not see.
I hook on entry events that program_b.p :
DEF VAR hField1 AS HANDLE.
DEF VAR hField2 AS HANDLE.
hField1 = getHandle( "field1", "frame1" ) . /* (This function is not important, works properly, returning handle to field in that frame) */
hField2 = getHandle( "field2", "frame1" ) .
/* Now i want to write something to field1 and go to field2 . */
IF FOCUS = field1
THEN DO:
field1:screen-value = 'something'.
APPLY "RETURN" TO field1. /* OR "ENTER" , doesn't matter because dont work */
PAUSE 0 NO-MESSAGE.
END.
PAUSE 0. /* Just in case */
And when in original program I entry on the field1 this program_b is executed.
But after updating field1 its freezing and waiting for any key. (its not "Press space bar to continue" ) . After 'anykey' its enter field2. In field2 i have no such problem. Its automatic goes to field3. And on field3 the same problem. Other fields ( i have 7 ) are working properly. Only field1 and field3 is causing this freeze.
You are only showing small snippets and not enough code to really say what is going on but:
RETURN NO-APPLY.
Is chicken soup for triggers. Especially triggers that modify field contents within the UI. You might just try adding that to whatever it is that you are doing.
I am working from this example: http://jqueryui.com/demos/autocomplete/#remote and I am encoding the output like this:
$rows = array();
while($r = mysql_fetch_assoc($category_result))
{
$rows[] = $r;
error_log ("rows: ".$rows[0]);
}
echo json_encode($rows);
But the dropdown on the other side shows nothing. Here is my test page: http://problemio.com/test.php - if you enter "ho" it matches 2 results in the database, but they are not getting displayed for some reason. Any idea why?
Thanks!!
The properties should be named label and value. From the JQuery UI demo page you linked to:
The local data can be a simple Array of Strings, or it contains
Objects for each item in the array, with either a label or value
property or both. The label property is displayed in the suggestion
menu.
So you would need to rename category_name to label either in PHP or later on in your JavaScript source handler function. The latter would require you to replace the PHP URL with a callback function like in the remote example. That way you could get the data any way you want (e.g. by jQuery.getJSON()) and work with it before it gets handed over to the suggestion box.
Hope this helps.
Regarding your comment, this should do it:
$rows = array();
while ($r = mysql_fetch_array($category_result)) {
$rows[] = array("label" => $r["category_name"]);
}
echo json_encode($rows);