How to set width and height of text field in cakephp? - cakephp

In my application, I need to take input from the user for a column named 'body' in a table in the database.
My code in the .ctp file is:
echo $form->input('body',array('style'=>'width: 900px'));
In this way, i am able to specify the width of the body field which works fine. But, I want to specify the height as well.
I tried echo $form->input('body',array('style'=>'width: 900px height: 500px'));
echo $form->input('body',array('style'=>'width: 900px','style'=>'height: 500px'));
The first one doesnt work for either width or height and the second one modifies only the height but not the width.
Can someone please tell me how to overcome this issue.
Thank you very much in advance.

// in a css file.
.txtArea { width:900px; height:500px; }
// in your view
echo $form->input('body', array('class'=>'txtArea'));
would be the recommended and preferred manner.
Alternatively, make sure your inline CSS is correct:
echo $form->input('body', array('style'=>'width:900px; height:500px;'));
Your code appears to be missing a ;, and of course by specifying style twice you will be overwriting the previous value.

Related

How to click element with zero height with Capybara?

The error I'm getting is: element not interactable: element has zero size
I have an element with a button tag with text. However, the element.style has two attributes of 0px height (and 0px padding, if that matters).
The only workaround I've found is to interact with some other element that I can find (higher up in the hierarchy of the markup), and then use x and y offsets to click this button. However that ends up flaky because the size of the element can change, and the button is off to the lower right corner.
I'm willing to go the extra mile and calculate the proper coordinates, but I'm not able to figure out how to get the width of the element either. I'm also willing to just use some javascript to click as a last resort. Ideally I'd love to know if there is something more clean and elegant for this problem.
Thank you!
I think you can enable js for this test and use a trick for it.
Smth like that:
page.execute_script("$('#container img').css('height', '10px;')")
find('#container img').click
page.execute_script("$('#container img').css('height', '0')")
I ended up using actionbuilder to work around this problem, like this:
el = find('button', :text => '+ 1').native
actionbuilder = page.driver.browser.action # Use actionbuilder to workaround zero height button
actionbuilder.click(el).perform
I'm not sure if this is the way to go but that seems to have helped and maybe might help someone else out there.

Embed with out the value field

How can you have an embeded text field with out all I want it to say is "Total Damage" and then display the image...
I have tried just about every combination of leaving it blank value="" or value=None or leaving off the value but then you get an error saying it is required.
diceEmbed.add_field(name='Total Damage', value=None)
image of the embed
You can't actually set a value to None so you have to use a unicode as such:
embed.add_field(name="name", value='\u200')
This probably is not the best way of doing this, but it does work for me.
diceEmbed.add_field(name='Total Damage', value=** **)
You can use the unicode character for zero width space
embed.add_field(name='Total Damage', value='\u200b')
# You can also use it in the name

Is there any way to change the text size (font size) of specific blocks when you using asciidoc?

I need your help.
Now I am using AsciiDoc and AsciiDoctor to create some manuals.
I want texts smaller on some specific blocks, for example wide table, wide list, and so on, but not want main texts smaller.
Especially I need to make texts of wide tables smaller as my customer requests so.
Is there any way?
You mention lists and tables...
About lists, it can't be done as stated in AsciiDoctor Documentation:
Unsupported
Complex AsciiDoc markup is not permitted in attribute values, such as:
lists
multiple paragraphs
other whitespace-dependent markup types
As you can see, there it mentions multiple paragraphs, so while #EhmKah answer is a correct way to set a custom styling block, it won't be rendered as expected in a table/list as it's multi-paragraph.
The Built-in CSS class syntax is the way to go [small]#any phrases#
But in order to make this work in a table, you must set the cell type with a specifier in this case, the AsciiDoc specifier denoted by a
This means the cell (or column) will render supported AsciiDoc statements, attributes, etc.
Here's a working example:
[frame="none",grid="none"]
|====
a| image::images\logo.png[] a|[.small]#Autor: {author}#
|====
If you have tons of rows/columns, you don't have to manually apply the a to all of them. You can set the columns you need this behavior this way:
[cols="1a,2a",frame="none",grid="none"]
|====
| image::images\logo.png[] |[.small]#Autor: {author}#
|====
You can check its documentation for more about Column Formatting and you can check the Rendered table with variable widths and alignments sub section for more about AsciiDoc (a) and other specifiers.
docinfo.html + --attribute docinfo=shared
You can drop your CSS modifications into a file called docinfo.html:
<style>
/* Your custom CSS. */
</style>
and then build with:
asciidoctor --attribute docinfo=shared README.adoc
and that makes Asciidoctor 2.0.10 place docinfo.html at the bottom of the <head> element.
So you can override most of the default Asciidoctor style from there.
Then it's just a matter of understanding the generated HTML and previous style definitions to override them.
For image specifically, see also: How to set a custom image height for an image in Asciidoctor?
When you use a theme file, you can add a role to it like this:
role:
mycustomfont:
font-color: #333
font-size: 10
Now you can reference your newly created role right from your table cell:
a|[.mycustomfont]# some text #
I read something about
[small] and [%autofit] option https://github.com/asciidoctor/asciidoctor-pdf/issues/185 I never needed it so maybe you give it a try.
example-code
[small]
----
should be rendered in smaller font.
----
[%autofit]
----
really long text that doesn't want to fit on a single line with the default font size, so we'll make it shrink to fit.
----

Select Field display in weird ways

Here is a TAG
The white block is the select field
Here is the select field selected
Here is the code
Why is it expanding out of it's limit ? there is nothing fancy there?
I think the problem is with your layout type.Which layout you are working with?Try it after removing layout config and add
xtype:'textfield',
anchor:50%,
itemId:'field'
If you are to use
selectfield.setHtml() and set it to a String.
It will destroy display and display the String ahs the value.
It's better to use setText() to do so.

how to (programmatically) scroll to a specific line in gtktextview/gtksourceview

I am creating a text editor as a way of getting more familiar with C and gtk+. I am using gtk+-2.0 & gtksourceview-2.0, and gtk_scrolled_window . As a first attempt at creating a goto function browser I thought I would just simply create an array of functions found in the document and a corresponding array of lines on which they occur. I have that much done. I was surprised to find that there is no goto line capability that I can easily find in devhelp. It sounds like gtk_text_view_scroll_to_mark () is what I want (after creating a mark), but all the *scroll_to functions require a within_margin, which to be honest I don't really understand.:
From devhelp:
The effective screen for purposes of this function is reduced by a margin of size within_margin.
What does that mean?
Am I even close? How can I create this scroll to line number functionality?
Thanks.
UPDATE: The following three functions were used to scroll to a line in the buffer:
gtk_text_iter_set_line (&start, lineNums[9]);
gtk_text_buffer_add_mark (tbuffer, scroll2mark, &start);
gtk_text_view_scroll_to_mark (text_view, scroll2mark, 0.0, TRUE, 0.0, 0.17);
The last parameter of gtk_text_view_scroll_to_mark was used to get the target line number to line up with the very top line in the buffer. I imagine this parameter will not work on all screen sizes, but I have not tested it.
The gtk_text_view_scroll_mark_onscreen function got me close to the line number, but it was just a couple of lines off the bottom of the text area.
The within_margin parameter controls the area of the screen in which the scrolled-to text should appear or more precisely it sets the amount of space at the border of the screen in which the text should not appear.
This exists so that when you set use_align to false (i.e. you don't want the text to appear at a specific position on the screen), you can still make sure that the text doesn't appear directly at the top of bottom of the screen (which might be bad for readability purposes).
If you don't care at all about the position at which the text will appear, you can use g_text_view_scroll_mark_on_screen which only takes the text view and a mark and no further arguments. This will always scroll the minimum amount to make the text appear on screen.

Resources